From 19bd6882d1f922dfcd99b1af957fa0a06a87ca49 Mon Sep 17 00:00:00 2001 From: "as2252258@163.com" Date: Sat, 3 Jul 2021 13:41:45 +0800 Subject: [PATCH] modify --- Database/Connection.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Database/Connection.php b/Database/Connection.php index b4389167..1d55957c 100644 --- a/Database/Connection.php +++ b/Database/Connection.php @@ -266,14 +266,12 @@ class Connection extends Component public function createCommand($sql = null, array $attributes = []): Command { $substr = strtoupper(substr($sql, 0, 6)); - - var_dump($substr); - $sql = match ($substr) { 'SELECT', 'SHOW F' => preg_replace('/FROM\s+(\w+)\s+/', 'FROM `' . $this->database . '`.$1 ', $sql), 'UPDATE' => preg_replace('/UPDATE\s+(\w+)\s+SET/', 'UPDATE `' . $this->database . '`.$1 SET', $sql), 'DELETE' => preg_replace('/DELETE FROM\s+(\w+)\s+/', 'DELETE FROM `' . $this->database . '`.$1', $sql), 'INSERT' => preg_replace('/INSERT INTO\s+(\w+)\s+/', 'INSERT INTO `' . $this->database . '`.$1', $sql), + 'TRUNCA' => preg_replace('/TRUNCATE\s+(\w+)\s+/', 'TRUNCATE `' . $this->database . '`.$1', $sql), default => throw new Exception('database error') }; $command = new Command(['db' => $this, 'sql' => $sql]);