示例#1
0
文件: Builder.php 项目: vgrish/dvelum
 /**
  * Remove object
  *
  * @param string $name
  * @return boolean
  */
 public function remove()
 {
     if ($this->_objectConfig->isLocked() || $this->_objectConfig->isReadOnly()) {
         $this->_errors[] = 'Can not remove locked object table ' . $this->_objectConfig->getName();
         return false;
     }
     try {
         $model = Model::factory($this->_objectName);
         if (!$this->tableExists()) {
             return true;
         }
         $sql = 'DROP TABLE `' . $model->table() . '`';
         $model->getDbConnection()->query($sql);
         $this->_logSql($sql);
         return true;
     } catch (Exception $e) {
         $this->_errors[] = $e->getMessage() . ' <br>SQL: ' . $sql;
         return false;
     }
 }