yii\db\Migration::delete PHP Method

delete() public method

Creates and executes a DELETE SQL statement.
public delete ( string $table, array | string $condition = '', array $params = [] )
$table string the table where the data will be deleted from.
$condition array | string the conditions that will be put in the WHERE part. Please refer to [[Query::where()]] on how to specify conditions.
$params array the parameters to be bound to the query.
    public function delete($table, $condition = '', $params = [])
    {
        echo "    > delete from {$table} ...";
        $time = microtime(true);
        $this->db->createCommand()->delete($table, $condition, $params)->execute();
        echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
    }

Usage Example

示例#1
0
 /**
  * @inheritdoc
  * Note: table will be auto pefixied if [[$autoWrapTableNames]] is true.
  */
 public function delete($table, $condition = '', $params = [])
 {
     $table = $this->autoWrappedTableName($table);
     return parent::delete($table, $condition, $params);
 }