dropColumn() public method

Builds and executes a SQL statement for dropping a DB column.
public dropColumn ( string $table, string $column )
$table string the table whose column is to be dropped. The name will be properly quoted by the method.
$column string the name of the column to be dropped. The name will be properly quoted by the method.
Exemplo n.º 1
0
 /**
  * Drop multiple columns to a table
  * @param string $table
  * @param array $columns ["column_name"=>type]
  */
 public function dropColumns($table, $columns)
 {
     foreach ($columns as $column => $type) {
         parent::dropColumn($table, $column);
     }
 }
Exemplo n.º 2
0
 /**
  * @throws \yii\base\NotSupportedException
  */
 public function afterDelete()
 {
     parent::afterDelete();
     $cm = $this->cm;
     $mg = new Migration();
     $table = Cm::$TAB_PREFIX[$cm->tab_index] . $cm->tab;
     $tableSchema = $mg->db->getSchema()->getTableSchema('{{%' . $table . '}}');
     if ($tableSchema === null) {
         return;
     }
     $columns = $tableSchema->getColumnNames();
     if (in_array($this->name, $columns)) {
         $mg->dropColumn('{{%' . $table . '}}', $this->name);
     }
 }
Exemplo n.º 3
0
 /**
  * @inheritdoc
  * Note: table will be auto pefixied if [[$autoWrapTableNames]] is true.
  */
 public function dropColumn($table, $column)
 {
     $table = $this->autoWrappedTableName($table);
     return parent::dropColumn($table, $column);
 }
Exemplo n.º 4
0
 public function dropColumn($table, $column, $type = null)
 {
     if ($type instanceof ForeignKeyColumn) {
         $type->migrate = $this;
         $type->sourceTable($table);
         $type->sourceColumn($column);
         $type->remove();
     }
     return parent::dropColumn($table, $column);
 }