From c7bc8d634736e1f45f9f30fc382f4b64ad4c1a95 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Fri, 27 May 2016 12:17:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BModel=E7=B1=BB=E7=9A=84scope?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Model.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/library/think/Model.php b/library/think/Model.php index c5b11bad..e468d3a8 100644 --- a/library/think/Model.php +++ b/library/think/Model.php @@ -702,7 +702,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess /** * 命名范围 * @access public - * @param string|Closure $name 命名范围名称 逗号分隔 + * @param string|array|Closure $name 命名范围名称 逗号分隔 * @param mixed $params 参数调用 * @return \think\Model */ @@ -715,9 +715,11 @@ abstract class Model implements \JsonSerializable, \ArrayAccess } elseif ($name instanceof Query) { return $name; } else { - $names = explode(',', $name); + if (is_string($name)) { + $names = explode(',', $name); + } foreach ($names as $scope) { - $method = 'scope' . $scope; + $method = 'scope' . trim($scope); if (method_exists($model, $method)) { $model->$method($query, $params); }