コード例 #1
0
ファイル: DBUtil.php プロジェクト: rmaiwald/core
 /**
  * Delete a database table.
  *
  * @param string $table Table a tablename key for the tables structure.
  *
  * @return boolean
  * @throws Exception If the $table parameter is empty or does not point to valid table definition.
  */
 public static function dropTable($table)
 {
     if (empty($table)) {
         throw new Exception(__f('The parameter %s must not be empty', 'table'));
     }
     $tables = self::getTables();
     $tableName = $tables[$table];
     if (empty($tableName)) {
         throw new Exception(__f('%s does not point to a valid table definition', $table));
     }
     try {
         Doctrine_Manager::getInstance()->getCurrentConnection()->export->dropTable($tableName);
         ObjectUtil::deleteAllObjectTypeAttributes($table);
     } catch (Exception $e) {
         return LogUtil::registerError(__('Error! Table drop failed.') . ' ' . $e->getMessage());
     }
     self::flushCache($table);
     return true;
 }