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 = [];