From e63a162bc7483545a78e9d286c3b6b5288053d55 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Fri, 9 Sep 2016 20:40:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BRoute?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Route.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/library/think/Route.php b/library/think/Route.php index 9e5a350b..fb68d3cc 100644 --- a/library/think/Route.php +++ b/library/think/Route.php @@ -1339,11 +1339,13 @@ class Route $result = call_user_func_array($val, [$matches]); } else { if (is_array($val)) { - $fields = explode('&', $val[1]); - $model = $val[0]; + $fields = explode('&', $val[1]); + $model = $val[0]; + $exception = isset($val[2]) ? $val[2] : true; } else { - $fields = ['id']; - $model = $val; + $fields = ['id']; + $model = $val; + $exception = true; } $where = []; $match = true; @@ -1356,7 +1358,7 @@ class Route } } if ($match) { - $result = $model::where($where)->findOrFail(); + $result = $model::where($where)->failException($exception)->find(); } } if (!empty($result)) {