yii\db\Migration::truncateTable PHP Method

truncateTable() public method

Builds and executes a SQL statement for truncating a DB table.
public truncateTable ( string $table )
$table string the table to be truncated. The name will be properly quoted by the method.
    public function truncateTable($table)
    {
        echo "    > truncate table {$table} ...";
        $time = microtime(true);
        $this->db->createCommand()->truncateTable($table)->execute();
        echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
    }

Usage Example

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