From 08e0261ad3bc9e5e69d7befdf746db45eb77fff7 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 22 Mar 2017 18:49:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A8=A1=E5=9E=8B=E7=B1=BB=E7=9A=84get?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E7=AC=AC=E4=B8=80=E4=B8=AA=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E5=BF=85=E9=A1=BB=20=E5=A6=82=E6=9E=9C=E4=BC=A0=E5=85=A5null?= =?UTF-8?q?=E5=88=99=E8=BF=94=E5=9B=9Enull?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Model.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/library/think/Model.php b/library/think/Model.php index 5d050c51..7ddec10c 100644 --- a/library/think/Model.php +++ b/library/think/Model.php @@ -1294,11 +1294,15 @@ abstract class Model implements \JsonSerializable, \ArrayAccess * @param mixed $data 主键值或者查询条件(闭包) * @param array|string $with 关联预查询 * @param bool $cache 是否缓存 - * @return static + * @return static|null * @throws exception\DbException */ - public static function get($data = null, $with = [], $cache = false) + public static function get($data, $with = [], $cache = false) { + if (is_null($data)) { + return null; + } + if (true === $with || is_int($with)) { $cache = $with; $with = [];