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);