From 0e3bfbe06c60fe5d19ed76cc1b5c4c870c776c94 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Mon, 2 Jan 2017 20:39:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96Connection=E7=9A=84=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db/Connection.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/library/think/db/Connection.php b/library/think/db/Connection.php index b43a1ddb..ef56c6fd 100644 --- a/library/think/db/Connection.php +++ b/library/think/db/Connection.php @@ -337,7 +337,7 @@ abstract class Connection $this->queryStr = $this->getRealSql($sql, $bind); //释放前次的查询结果 - if (!empty($this->PDOStatement)) { + if (!empty($this->PDOStatement) && $this->PDOStatement->queryString != $sql) { $this->free(); } @@ -346,11 +346,13 @@ abstract class Connection // 调试开始 $this->debug(true); // 预处理 - $this->PDOStatement = $this->linkID->prepare($sql); + if (empty($this->PDOStatement)) { + $this->PDOStatement = $this->linkID->prepare($sql); + } // 参数绑定 $this->bindValue($bind); // 执行查询 - $result = $this->PDOStatement->execute(); + $this->PDOStatement->execute(); // 调试结束 $this->debug(false); $procedure = in_array(strtolower(substr(trim($sql), 0, 4)), ['call', 'exec']); @@ -379,7 +381,7 @@ abstract class Connection $this->queryStr = $this->getRealSql($sql, $bind); //释放前次的查询结果 - if (!empty($this->PDOStatement)) { + if (!empty($this->PDOStatement) && $this->PDOStatement->queryString != $sql) { $this->free(); } @@ -388,11 +390,13 @@ abstract class Connection // 调试开始 $this->debug(true); // 预处理 - $this->PDOStatement = $this->linkID->prepare($sql); + if (empty($this->PDOStatement)) { + $this->PDOStatement = $this->linkID->prepare($sql); + } // 参数绑定操作 $this->bindValue($bind); // 执行语句 - $result = $this->PDOStatement->execute(); + $this->PDOStatement->execute(); // 调试结束 $this->debug(false);