Jump to main content Jump to doc navigation


Drops a table if it exists.

This will only work if there is a corresponding xPDO class for the table and its package has been loaded. MODX will not drop the table if the ORM layer has not defined the table.


API Docs: removeObjectContainer

int removeObjectContainer (string $className)


Drop the table associated with the "Person" object:

$manager = $xpdo->getManager();


If you are trying to remove tables after having removed or renamed the underlying xPDO classes, you may need to resort to issuing a manual "DROP TABLE" query.

$removed = $modx->exec('DROP TABLE IF EXISTS your_table');
if ($removed === false && $modx->errorCode() !== '' && $modx->errorCode() !== PDO::ERR_NONE) {
    print 'Could not drop table! ERROR: ' . print_r($modx->pdo->errorInfo(),true);
else {
    print 'Table dropped successfully.';

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.


  • modmore
  • Jens Wittmann – Gestaltung & Entwicklung
  • Fabian Christen
  • Dannevang Digital
  • Digital Penguin
  • Sepia River Studios
  • CrewMark
  • Chris Fickling
  • deJaya
  • Following Sea
  • Anton Tarasov
  • eydolan
  • Raffy
  • Lefthandmedia
  • Murray Wood
  • Nick Clark
  • Snow Creative
  • Helen
  • JT Skaggs
  • krisznet
  • YJ
  • Yanni
  • Richard


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

Learn more