From 9a670f626eac30a6546f5caeb7c15d6d294cf842 Mon Sep 17 00:00:00 2001 From: whwyy Date: Wed, 13 Dec 2023 16:25:17 +0800 Subject: [PATCH] eee --- Base/Model.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Base/Model.php b/Base/Model.php index 89b1804..03fd71e 100644 --- a/Base/Model.php +++ b/Base/Model.php @@ -235,7 +235,7 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, \ * @return Model|null * @throws */ - public static function findOne(int|string|array $param, $db = NULL): static|null|bool + public static function findOne(int|string|array $param, $db = NULL): ?static { $model = static::instance(); @@ -248,7 +248,11 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, \ } else { $query->whereRaw($param); } - return $query->first(); + $data = $query->first(); + if ($data === false) { + throw new Exception($model->getLastError()); + } + return $data; }