diff --git a/SinglePHP.php b/SinglePHP.php index e884a0b0dcdfe1eed7f93ffaebcfbacd5e78187d..8f2a56e76535e28a2657b3cfdd89504de201a5cd 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() {