Пример #1
0
 /**
  * Generate the SQL to truncate a table.
  *
  * @param TableSchema $table Table instance.
  * @return array SQL statements to truncate a table.
  */
 public function truncateTableSql(TableSchema $table)
 {
     $sql = sprintf('DROP TABLE %s CASCADE', $this->_driver->quoteIdentifier($table->name()));
     return [$sql];
 }
Пример #2
0
 /**
  * Generate the SQL to truncate a table.
  *
  * @param TableSchema $table Table instance.
  * @return array SQL statements to truncate a table.
  */
 public function truncateTableSql(TableSchema $table)
 {
     return [sprintf('TRUNCATE TABLE `%s`', $table->name())];
 }
Пример #3
0
 /**
  * Generate the SQL to truncate a table.
  *
  * @param TableSchema $table Table instance.
  * @return array SQL statements to truncate a table.
  */
 public function truncateTableSql(TableSchema $table)
 {
     $name = $this->_driver->quoteIdentifier($table->name());
     $queries = [sprintf('DELETE FROM %s', $name)];
     // Restart identity sequences
     $pk = $table->primaryKey();
     if (count($pk) === 1) {
         $column = $table->column($pk[0]);
         if (in_array($column['type'], ['integer', 'biginteger'])) {
             $queries[] = sprintf('DBCC CHECKIDENT(%s, RESEED, 0)', $name);
         }
     }
     return $queries;
 }
Пример #4
0
 /**
  * Generate the SQL to truncate a table.
  *
  * @param TableSchema $table Table instance.
  * @return array SQL statements to truncate a table.
  */
 public function truncateTableSql(TableSchema $table)
 {
     $name = $table->name();
     $sql = [];
     if ($this->hasSequences()) {
         $sql[] = sprintf('DELETE FROM sqlite_sequence WHERE name="%s"', $name);
     }
     $sql[] = sprintf('DELETE FROM "%s"', $name);
     return $sql;
 }