diff --git a/library/think/db/Query.php b/library/think/db/Query.php index eaa90e5d..43cfd300 100644 --- a/library/think/db/Query.php +++ b/library/think/db/Query.php @@ -1782,6 +1782,34 @@ class Query return $data; } + /** + * 查找多条记录 如果不存在则抛出异常 + * @access public + * @param array|string|Query|\Closure $data + * @return array|\PDOStatement|string|Model + * @throws DbException + * @throws Exception + * @throws PDOException + */ + public function selectOrFail($data=[]) + { + return $this->failException(true)->select($data); + } + + /** + * 查找单条记录 如果不存在则抛出异常 + * @access public + * @param array|string|Query|\Closure $data + * @return array|\PDOStatement|string|Model + * @throws DbException + * @throws Exception + * @throws PDOException + */ + public function findOrFail($data=[]) + { + return $this->failException(true)->find($data); + } + /** * 分批数据返回处理 * @access public