From dae8edebddb6021508a9ea74bda13bea062a6c87 Mon Sep 17 00:00:00 2001 From: yangmeishu Date: Thu, 17 Apr 2025 22:25:30 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=84=E8=8C=83sql=E8=AF=AD=E5=8F=A5?= =?UTF-8?q?=EF=BC=8C=E6=94=AF=E6=8C=81sqlite=E3=80=82=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E6=89=93=E5=8D=B0sql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SinglePHP.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/SinglePHP.php b/SinglePHP.php index e884a0b..8f2a56e 100644 --- a/SinglePHP.php +++ b/SinglePHP.php @@ -496,6 +496,9 @@ class DB { * @throws \Exception */ private function execute($sql, $bind=array(), $flag = '') { + if (APP_DEBUG){ + Log::debug("SQL: {$sql} \nBIND: " . sp_tojson($bind)); + } $this->_lastSql = $sql; try { $stmt = $this->_db->prepare($sql); @@ -636,7 +639,7 @@ class Model { * @return boolean|array */ public function select() { - $_sql = 'SELECT * FROM ' . $this->_table ." WHERE ". $this->_where; + $_sql = "SELECT * FROM `{$this->_table}` WHERE {$this->_where}"; $info = $this->_db->select($_sql, $this->_bind); $this->clean(); return $info; @@ -662,7 +665,7 @@ class Model { $keys = substr($keys, 0, -1); $this->_bind = array_merge($this->_bind, $_bind); - $_sql = 'UPDATE ' . $this->_table . " SET {$keys} WHERE ". $this->_where; + $_sql = "UPDATE `{$this->_table}` SET {$keys} WHERE {$this->_where}"; $info = $this->_db->update($_sql, $this->_bind); $this->clean(); return $info; @@ -675,7 +678,7 @@ class Model { public function delete($id=null) { if ($id != null) $this->where(array($this->_pk => $id)); - $_sql = 'DELETE FROM ' . $this->_table ." WHERE ". $this->_where; + $_sql = "DELETE FROM `{$this->_table}` WHERE {$this->_where}"; $info = $this->_db->delete($_sql, $this->_bind); $this->clean(); return $info; @@ -694,7 +697,7 @@ class Model { } $keys = substr($keys, 0, -1); $vals = substr($vals, 0, -1); - $_sql = 'INSERT INTO ' . $this->_table . " ($keys) VALUES ($vals)"; + $_sql = "INSERT INTO `{$this->_table}` ({$keys}) VALUES ({$vals})"; return $this->_db->insert($_sql, $_bind); } private function clean() { -- Gitee