Jump to main content Jump to doc navigation

xPDOManager::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

  • modmore
  • Jens Wittmann – Gestaltung & Entwicklung
  • Digital Penguin
  • eydolan
  • deJaya
  • Following Sea
  • Sepia River Studios
  • Nick Clark
  • Lefthandmedia
  • YJ
  • Murray Wood
  • Dannevang Digital
  • Richard

Budget

$217 per month—let's make that $500!

Learn more