failException(链式操作20)
用于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();