From b7bf4dfaba520d7371d354334411f707c937f4d0 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Fri, 8 Apr 2016 18:41:06 +0800 Subject: [PATCH] =?UTF-8?q?Model=E7=B1=BB=E5=A2=9E=E5=8A=A0scope=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Model.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/library/think/Model.php b/library/think/Model.php index 38421202..1ef0b2c9 100644 --- a/library/think/Model.php +++ b/library/think/Model.php @@ -614,6 +614,13 @@ abstract class Model implements \JsonSerializable, \ArrayAccess return $result; } + // 命名范围 + public static function scope($name) + { + $model = new static(); + return $model->$name(); + } + // 解析模型的完整命名空间 protected function parseModel($model) {