From faff79e2ac711d828edc511fdf4947a1d28562c1 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Thu, 21 Apr 2016 18:04:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9Bquery=E7=B1=BB=E7=9A=84value?= =?UTF-8?q?=E5=92=8Ccolumn=E6=96=B9=E6=B3=95=E7=9A=84=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Model.php | 9 +++++++-- library/think/db/Query.php | 6 ++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/library/think/Model.php b/library/think/Model.php index 501be6fa..bc390fd0 100644 --- a/library/think/Model.php +++ b/library/think/Model.php @@ -605,7 +605,9 @@ abstract class Model implements \JsonSerializable, \ArrayAccess $model = $class->$relation(); $info = $class->getRelationInfo(); $table = $info['model']::getTable(); - return self::db()->alias('a')->join($table . ' b', 'a.' . $info['localKey'] . '=b.' . $info['foreignKey'])->group('b.' . $info['foreignKey']) + return self::db()->alias('a') + ->join($table . ' b', 'a.' . $info['localKey'] . '=b.' . $info['foreignKey']) + ->group('b.' . $info['foreignKey']) ->having('count(' . $id . ')' . $operator . $count); } @@ -630,7 +632,10 @@ abstract class Model implements \JsonSerializable, \ArrayAccess } } } - return self::db()->alias('a')->field('a.*')->join($table . ' b', 'a.' . $info['localKey'] . '=b.' . $info['foreignKey'])->where($where); + return self::db()->alias('a') + ->field('a.*') + ->join($table . ' b', 'a.' . $info['localKey'] . '=b.' . $info['foreignKey']) + ->where($where); } /** diff --git a/library/think/db/Query.php b/library/think/db/Query.php index 8901aa18..7f6ca17c 100644 --- a/library/think/db/Query.php +++ b/library/think/db/Query.php @@ -106,6 +106,9 @@ class Query // 缓存数据 Cache::set($key, $result, $cache['expire']); } + } else { + // 清空查询条件 + $this->options = []; } return $result; } @@ -149,6 +152,9 @@ class Query // 缓存数据 Cache::set($guid, $result, $cache['expire']); } + } else { + // 清空查询条件 + $this->options = []; } return $result; }