From 1e1f36eb40f950de86330bbf3d2420e34ad81bfc Mon Sep 17 00:00:00 2001 From: thinkphp Date: Thu, 9 Feb 2017 17:49:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BQuery=E7=B1=BB=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E6=9B=B4=E6=96=B0=20=E4=BF=AE=E6=AD=A3Connection?= =?UTF-8?q?=E7=B1=BB=E4=B8=80=E5=A4=84=E5=8F=AF=E8=83=BD=E7=9A=84=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db/Connection.php | 4 ++-- library/think/db/Query.php | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/library/think/db/Connection.php b/library/think/db/Connection.php index 0887093d..f166e916 100644 --- a/library/think/db/Connection.php +++ b/library/think/db/Connection.php @@ -365,8 +365,8 @@ abstract class Connection $this->bind = $bind; } - //释放前次的查询结果 - if (!empty($this->PDOStatement) && $this->PDOStatement->queryString != $sql) { + // 释放前次的查询结果 + if (!empty($this->PDOStatement)) { $this->free(); } diff --git a/library/think/db/Query.php b/library/think/db/Query.php index 5473b688..5e258d71 100644 --- a/library/think/db/Query.php +++ b/library/think/db/Query.php @@ -2204,6 +2204,8 @@ class Query if (isset($key) && Cache::get($key)) { // 删除缓存 Cache::rm($key); + } elseif (!empty($options['cache']['tag'])) { + Cache::clear($options['cache']['tag']); } // 执行操作 $result = '' == $sql ? 0 : $this->execute($sql, $bind); @@ -2377,6 +2379,8 @@ class Query } if (isset($data)) { return 'think:' . $options['table'] . '|' . $data; + } else { + return md5(serialize($options)); } } @@ -2648,6 +2652,8 @@ class Query if (isset($key) && Cache::get($key)) { // 删除缓存 Cache::rm($key); + } elseif (!empty($options['cache']['tag'])) { + Cache::clear($options['cache']['tag']); } // 执行操作 $result = $this->execute($sql, $bind);