コード例 #1
0
 /**
  * Destroys the MetaModel table and all associated entries in child tables like filter-, render- and dcasettings.
  *
  * @param DC_General $objDC the datacontainer where the model is loaded.
  *
  * @return void
  */
 public function onDeleteCallback(DC_General $objDC)
 {
     $objMetaModel = MetaModelFactory::byId($objDC->getId());
     if ($objMetaModel) {
         // TODO: implement IMetaModel*::suicide() to delete all entries in secondary tables (complex attributes), better than here in an callback.
         foreach ($objMetaModel->getAttributes() as $objAttribute) {
             $objAttribute->destroyAUX();
         }
         MetaModelTableManipulation::deleteTable($objMetaModel->getTableName());
         $this->Database->prepare('DELETE FROM tl_metamodel_attribute WHERE pid=?')->executeUncached($objMetaModel->get('id'));
         $this->Database->prepare('DELETE FROM tl_metamodel_dca_combine WHERE pid=?')->executeUncached($objMetaModel->get('id'));
         // delete everything from dca settings
         $arrIds = $this->Database->prepare('SELECT id FROM tl_metamodel_dca WHERE pid=?')->executeUncached($objMetaModel->get('id'))->fetchEach('id');
         if ($arrIds) {
             $this->Database->prepare(sprintf('DELETE FROM tl_metamodel_dcasetting WHERE pid IN (%s)', implode(',', $arrIds)))->executeUncached();
         }
         $this->Database->prepare('DELETE FROM tl_metamodel_dca WHERE pid=?')->executeUncached($objMetaModel->get('id'));
         // delete everything from render settings
         $arrIds = $this->Database->prepare('SELECT id FROM tl_metamodel_rendersettings WHERE pid=?')->executeUncached($objMetaModel->get('id'))->fetchEach('id');
         if ($arrIds) {
             $this->Database->prepare(sprintf('DELETE FROM tl_metamodel_rendersetting WHERE pid IN (%s)', implode(',', $arrIds)))->executeUncached();
         }
         $this->Database->prepare('DELETE FROM tl_metamodel_rendersettings WHERE pid=?')->executeUncached($objMetaModel->get('id'));
         // delete everything from filter settings
         $arrIds = $this->Database->prepare('SELECT id FROM tl_metamodel_filter WHERE pid=?')->executeUncached($objMetaModel->get('id'))->fetchEach('id');
         if ($arrIds) {
             $this->Database->prepare(sprintf('DELETE FROM tl_metamodel_filtersetting WHERE pid IN (%s)', implode(',', $arrIds)))->executeUncached();
         }
         $this->Database->prepare('DELETE FROM tl_metamodel_filter WHERE pid=?')->executeUncached($objMetaModel->get('id'));
     }
 }