xPDOManager.createObjectContainer
Last updated Apr 6th, 2019 | Page history | Improve this page | Report an issue
Support the team building MODX with a monthly donation.
The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.
Backers
Budget
$306 per month—let's make that $500!
Learn morexPDOManager::createObjectContainer()¶
Creates the container for a persistent data object. In this implementation, a source container is a synonym for a MySQL database table. The table name will be generated by the schema; related tables will not be created, however.
Syntax¶
API Docs: createObjectContainer
void createObjectContainer (string $className)
Examples¶
Create the table for the class 'Person':
$manager = $xpdo->getManager();
$manager->createObjectContainer('Person');
If you need to do this in a MODX Snippet, you'd use the $modx object, and you'd have to make sure you added your package (and its model classes) first:
$modx->addPackage('yourpkg',MODX_CORE_PATH.'components/yourpkg/model/','prefix_');
$manager = $modx->getManager();
$manager->createObjectContainer('Myobject');
Note that the database prefix here is independent of the MODX prefix. You may have modx_
for your MODX prefix and mypkg_
for your package's tables.
Support the team building MODX with a monthly donation.
The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.
Backers
Budget
$306 per month—let's make that $500!
Learn more