yii\db\Migration::dropColumn PHP Method

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.
    public function dropColumn($table, $column)
    {
        echo "    > drop column {$column} from table {$table} ...";
        $time = microtime(true);
        $this->db->createCommand()->dropColumn($table, $column)->execute();
        echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
    }

Usage Example

コード例 #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);
     }
 }
All Usage Examples Of yii\db\Migration::dropColumn