From a3a564bc6d993e97ad6b740f25ee800f6e17ccfe Mon Sep 17 00:00:00 2001 From: thinkphp Date: Mon, 23 Apr 2018 16:36:59 +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 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/library/think/Model.php b/library/think/Model.php index 9c3407d3..8c9679b8 100644 --- a/library/think/Model.php +++ b/library/think/Model.php @@ -118,9 +118,9 @@ abstract class Model implements \JsonSerializable, \ArrayAccess /** * 是否从主库读取(主从分布式有效) - * @var bool + * @var array */ - protected static $readMaster = false; + protected static $readMaster; /** * 构造方法 @@ -185,7 +185,9 @@ abstract class Model implements \JsonSerializable, \ArrayAccess */ public function readMaster($master) { - static::$readMaster = $master; + if ($master) { + static::$readMaster[$this->class] = true; + } } /** @@ -211,7 +213,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess $queryClass = $this->query ?: $con->getConfig('query'); $query = new $queryClass($con, $this); - if (static::$readMaster) { + if (isset(static::$readMaster[$this->class])) { $query->master(true); }