MetaModels\Helper\TableManipulation::dropColumn PHP Метод

dropColumn() публичный статический Метод

Throws Exception if the table does not exist, the column name is invalid or the column does not exist.
public static dropColumn ( string $strTableName, string $strColumnName, boolean $blnAllowSystemCol = false ) : void
$strTableName string The name of the table the column is in.
$strColumnName string The name of the column to drop.
$blnAllowSystemCol boolean If this is set to true, no system column name checking will be applied.
Результат void
    public static function dropColumn($strTableName, $strColumnName, $blnAllowSystemCol = false)
    {
        self::checkColumnExists($strTableName, $strColumnName, $blnAllowSystemCol);
        self::getDB()->execute(sprintf(self::STATEMENT_DROP_COLUMN, $strTableName, $strColumnName));
    }

Usage Example

Пример #1
0
 /**
  * Removes the underlying database structure for this field.
  *
  * @return void
  */
 public function deleteColumn()
 {
     // Try to delete the column. If it does not exist as we can assume it has been deleted already then.
     if ($this->getColName() && $this->getMetaModel()->getServiceContainer()->getDatabase()->fieldExists($this->getColName(), $this->getMetaModel()->getTableName(), true)) {
         TableManipulation::dropColumn($this->getMetaModel()->getTableName(), $this->getColName());
     }
 }