mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
Query类增加findOrFail selectOrFail快捷方法
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user