From bdd28d9b273edb3c6ebfaf7112f1962aaad4a23d Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sun, 31 Jan 2016 22:14:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=20\think\db\Driver=E7=B1=BB?= =?UTF-8?q?=E7=9A=84getBindSql=E6=96=B9=E6=B3=95=E7=9A=84=E4=B8=80?= =?UTF-8?q?=E5=A4=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db/Driver.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/library/think/db/Driver.php b/library/think/db/Driver.php index 82d66cf6..a4dc4125 100644 --- a/library/think/db/Driver.php +++ b/library/think/db/Driver.php @@ -60,8 +60,6 @@ abstract class Driver 'charset' => 'utf8', // 数据库表前缀 'prefix' => '', - // 数据库调试模式 - 'debug' => false, // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器) 'deploy' => 0, // 数据库读写是否分离 主从式有效 @@ -197,7 +195,7 @@ abstract class Driver $this->debug(false); return $this->getResult(); } catch (\PDOException $e) { - throw new Exception($this->getError()); + throw new Exception($e->getMessage() . "\n [ SQL语句 ] : " . $this->queryStr); } } @@ -247,7 +245,7 @@ abstract class Driver } return $this->numRows; } catch (\PDOException $e) { - throw new Exception($this->getError()); + throw new Exception($e->getMessage() . "\n [ SQL语句 ] : " . $this->queryStr); } } @@ -266,7 +264,7 @@ abstract class Driver // 判断占位符 $sql = is_numeric($key) ? substr_replace($sql, $val, strpos($sql, '?'), 1) : - str_replace(':' . $key, $val, $sql); + str_replace(':' . $key . ' ', $val . ' ', $sql); } } return $sql; @@ -291,9 +289,6 @@ abstract class Driver } else { $result = $this->PDOStatement->bindValue($param, $val); } - if (!$result) { - throw new Exception('bind param error : [ ' . $param . '=>' . $val . ' ]'); - } } }