failException
设置查询数据为空时是否需要抛出异常,如果不传入任何参数,默认为开启,用于select
和find
方法,例如:
Db::name('blog')
->where(['status' => 1])
->failException()
->select();
Db::name('blog')
->where(['status' => 1])
->failException(false)
->select();
或者可以使用更方便的查空报错
Db::name('blog')
->where(['status' => 1])
->selectOrFail();
Db::name('blog')
->where(['status' => 1])
->findOrFail();