Ejemplo n.º 1
0
 /**
  * Deletes report object
  *
  * @return void
  **/
 public function delete()
 {
     // проверим права доступа на запись отчета
     $this->_mapper->access($this, 'DELETE');
     $result = parent::delete();
     if ($result) {
         $this->_mapper->_deleteCollection('hide', $this);
         $this->_mapper->_deleteCollection('group', $this);
         // delete related objects
         $this->removeAllDiagrams();
         $this->removeAllValues();
         $this->removeAllRestrictions();
         // delete related tables
         $table_name = $this->getTableName();
         M('Db')->setCurrentConnection('storage');
         foreach (M('Db')->query('SHOW TABLES LIKE ?', $table_name . '%') as $row) {
             M('Db')->exec('DROP TABLE IF EXISTS ' . array_pop($row));
         }
         M('Db')->setCurrentConnection('default');
         // TODO:
         // delete permissions
     }
     return $result;
 }