From 739f8bef18b5c42e4008edf799f9d05af59e01e4 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sun, 11 Sep 2016 12:20:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E5=85=B3=E8=81=94=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E9=A2=84=E8=BD=BD=E5=85=A5=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E9=97=AD=E5=8C=85=E4=BD=BF=E7=94=A8=E6=9D=A1=E4=BB=B6=E4=B9=8B?= =?UTF-8?q?=E5=A4=96=E7=9A=84=E8=BF=9E=E8=B4=AF=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db/Builder.php | 2 +- library/think/model/Relation.php | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/library/think/db/Builder.php b/library/think/db/Builder.php index 11f372da..8fa87d39 100644 --- a/library/think/db/Builder.php +++ b/library/think/db/Builder.php @@ -94,7 +94,7 @@ abstract class Builder if ($options['strict']) { throw new Exception('fields not exists:[' . $key . ']'); } - } else if (isset($val[0]) && 'exp' == $val[0]) { + } elseif (isset($val[0]) && 'exp' == $val[0]) { $result[$item] = $val[1]; } elseif (is_null($val)) { $result[$item] = 'NULL'; diff --git a/library/think/model/Relation.php b/library/think/model/Relation.php index 1dc43e6e..48d7851f 100644 --- a/library/think/model/Relation.php +++ b/library/think/model/Relation.php @@ -339,7 +339,10 @@ class Relation { $foreignKey = $this->foreignKey; // 预载入关联查询 支持嵌套预载入 - $list = $model->where($where)->where($closure)->with($subRelation)->select(); + if ($closure) { + call_user_func_array($closure, [ & $model]); + } + $list = $model->where($where)->with($subRelation)->select(); // 组装模型数据 $data = [];