From 539d4645b98b07c9d6c6cae0e971df2a1386fca2 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Fri, 19 Jul 2024 21:13:34 +1200 Subject: [PATCH] FIX Truncate table to clear table --- src/ORM/Connect/MySQLDatabase.php | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/ORM/Connect/MySQLDatabase.php b/src/ORM/Connect/MySQLDatabase.php index b0633d20a..0aeb6067f 100644 --- a/src/ORM/Connect/MySQLDatabase.php +++ b/src/ORM/Connect/MySQLDatabase.php @@ -566,16 +566,6 @@ class MySQLDatabase extends Database implements TransactionManager */ public function clearTable($table) { - $this->query("DELETE FROM \"$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"); - } + $this->query("TRUNCATE TABLE \"$table\""); } }