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.';