From 4a882963d6bc6779f46e020e919f245c88d30138 Mon Sep 17 00:00:00 2001 From: yunwuxin <448901948@qq.com> Date: Mon, 8 Oct 2018 15:18:54 +0800 Subject: [PATCH] =?UTF-8?q?Query=E6=94=AF=E6=8C=81=E8=B0=83=E7=94=A8?= =?UTF-8?q?=E6=A8=A1=E5=9E=8B=E7=9A=84=E6=9F=A5=E8=AF=A2=E8=8C=83=E5=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db/Query.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/library/think/db/Query.php b/library/think/db/Query.php index b63c38e5..fac05003 100644 --- a/library/think/db/Query.php +++ b/library/think/db/Query.php @@ -92,6 +92,13 @@ class Query $name = Loader::parseName(substr($method, 10)); $where[$name] = $args[0]; return $this->where($where)->value($args[1]); + } elseif ($this->model && method_exists($this->model, 'scope' . $method)) { + // 动态调用命名范围 + $method = 'scope' . $method; + array_unshift($args, $this); + + call_user_func_array([$this->model, $method], $args); + return $this; } else { throw new Exception('method not exist:' . __CLASS__ . '->' . $method); }