From dfb92fa9dd17b4c718ddabd1cbd6dab5c999c5cc Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 17 Aug 2016 11:17:03 +0800 Subject: [PATCH] =?UTF-8?q?Query=E7=B1=BB=E7=9A=84update=E5=92=8Cdelete?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E6=94=AF=E6=8C=81=E8=B0=83=E7=94=A8cache?= =?UTF-8?q?=E6=96=B9=E6=B3=95=20=E4=BC=9A=E8=87=AA=E5=8A=A8=E6=B8=85?= =?UTF-8?q?=E9=99=A4=E6=8C=87=E5=AE=9Akey=E7=9A=84=E7=BC=93=E5=AD=98=20?= =?UTF-8?q?=E9=85=8D=E5=90=88=E6=9F=A5=E8=AF=A2=E6=96=B9=E6=B3=95=E7=9A=84?= =?UTF-8?q?cache=E6=96=B9=E6=B3=95=E4=B8=80=E8=B5=B7=E4=BD=BF=E7=94=A8=20M?= =?UTF-8?q?odel=E7=B1=BB=E7=9A=84get=E6=96=B9=E6=B3=95=E7=AC=AC=E4=B8=89?= =?UTF-8?q?=E4=B8=AA=E5=8F=82=E6=95=B0=E4=BC=A0=E5=85=A5true=E7=9A=84?= =?UTF-8?q?=E6=97=B6=E5=80=99=E4=BC=9A=E8=87=AA=E5=8A=A8=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Model.php | 3 --- library/think/db/Query.php | 7 +++++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/library/think/Model.php b/library/think/Model.php index e4306697..cb7bd21f 100644 --- a/library/think/Model.php +++ b/library/think/Model.php @@ -985,9 +985,6 @@ abstract class Model implements \JsonSerializable, \ArrayAccess */ public static function get($data = null, $with = [], $cache = false) { - if (!$cache && $data && is_scalar($data)) { - $cache = true; - } $query = static::parseQuery($data, $with, $cache); return $query->find($data); } diff --git a/library/think/db/Query.php b/library/think/db/Query.php index a3e8ac2e..f49d7d3d 100644 --- a/library/think/db/Query.php +++ b/library/think/db/Query.php @@ -1769,6 +1769,10 @@ class Query { $options = $this->parseExpress(); $pk = $this->getPk($options); + if (isset($options['cache']) && is_string($options['cache'])) { + $key = $options['cache']; + } + if (empty($options['where'])) { // 如果存在主键数据 则自动作为更新条件 if (is_string($pk) && isset($data[$pk])) { @@ -2095,6 +2099,9 @@ class Query { // 分析查询表达式 $options = $this->parseExpress(); + if (isset($options['cache']) && is_string($options['cache'])) { + $key = $options['cache']; + } if (!is_null($data) && true !== $data) { if (!is_array($data)) {