From 7ff02c61cd1b427e757aa56eafe715c96375b566 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 18 May 2016 22:39:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Model.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/think/Model.php b/library/think/Model.php index 7d5455b8..11ad857b 100644 --- a/library/think/Model.php +++ b/library/think/Model.php @@ -893,6 +893,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess } else { $query->name($this->name); } + self::$links[$model] = $query; } // 返回当前模型的数据库查询对象 @@ -916,8 +917,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess { $model = get_called_class(); if (!isset(self::$links[$model])) { - $class = new static(); - self::$links[$model] = $class->db(); + self::$links[$model] = (new static())->db(); } $query = self::$links[$model]; return call_user_func_array([$query, $method], $params);