From 04c81ca6b5c31f738ad21888b5ce26e4e4cb84ec Mon Sep 17 00:00:00 2001 From: thinkphp Date: Mon, 16 Jan 2017 17:03:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BModel=E7=B1=BB=E7=9A=84has?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E7=AC=AC=E4=BA=8C=E4=B8=AA=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=BD=BF=E7=94=A8=E6=95=B0=E7=BB=84=E6=88=96?= =?UTF-8?q?=E8=80=85=E9=97=AD=E5=8C=85=E8=BF=9B=E8=A1=8C=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E6=9D=A1=E4=BB=B6=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Model.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/library/think/Model.php b/library/think/Model.php index a6f11353..0e633c54 100644 --- a/library/think/Model.php +++ b/library/think/Model.php @@ -1228,7 +1228,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess * 根据关联条件查询当前模型 * @access public * @param string $relation 关联方法名 - * @param string $operator 比较操作符 + * @param mixed $operator 比较操作符 * @param integer $count 个数 * @param string $id 关联表的统计字段 * @return Model @@ -1236,6 +1236,9 @@ abstract class Model implements \JsonSerializable, \ArrayAccess public static function has($relation, $operator = '>=', $count = 1, $id = '*') { $model = new static(); + if (is_array($operator) || $operator instanceof \Closure) { + return $model->$relation()->hasWhere($model, $operator); + } return $model->$relation()->has($model, $operator, $count, $id); }