mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #11309 from creative-commoners/pulls/5.2/clear-table
FIX Truncate table to clear table
This commit is contained in:
commit
4693e3f378
@ -566,16 +566,6 @@ class MySQLDatabase extends Database implements TransactionManager
|
|||||||
*/
|
*/
|
||||||
public function clearTable($table)
|
public function clearTable($table)
|
||||||
{
|
{
|
||||||
$this->query("DELETE FROM \"$table\"");
|
$this->query("TRUNCATE TABLE \"$table\"");
|
||||||
|
|
||||||
// Check if resetting the auto-increment is needed
|
|
||||||
$autoIncrement = $this->preparedQuery(
|
|
||||||
'SELECT "AUTO_INCREMENT" FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = ? AND TABLE_NAME = ?',
|
|
||||||
[ $this->getSelectedDatabase(), $table]
|
|
||||||
)->value();
|
|
||||||
|
|
||||||
if ($autoIncrement > 1) {
|
|
||||||
$this->query("ALTER TABLE \"$table\" AUTO_INCREMENT = 1");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user