Query类增加findOrFail selectOrFail快捷方法

This commit is contained in:
thinkphp
2016-06-12 12:53:06 +08:00
parent ccd1e2c2e7
commit 9023041e6b

View File

@@ -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