繁体   English   中英

调用成员函数where()的数组

[英]Call to a member function where() on array

我有以下MySQL例程存储过程“ Sel_All_Observation_SP”:

    BEGIN
    SELECT Observations_TBL.observation_id, Observations_TBL.number, Observations_TBL.date, Observations_TBL.status, Observations_TBL.content, Observations_TBL.recommendation, Observations_TBL.remark, Users_TBL.User_name, Type_Name_TBL.Type_Name, Supervisors_TBL.supervisor_name
    FROM ((Observations_TBL INNER JOIN Supervisors_TBL ON (Supervisors_TBL.supervisor_id = Observations_TBL.supervisor_id) AND (Observations_TBL.supervisor_id = Supervisors_TBL.supervisor_id)) INNER JOIN Type_Name_TBL ON (Observations_TBL.Type_Name_ID = Type_Name_TBL.Type_Name_ID) AND (Observations_TBL.Type_Name_ID = Type_Name_TBL.Type_Name_ID)) INNER JOIN Users_TBL ON (Users_TBL.User_ID = Observations_TBL.user_id) AND (Observations_TBL.user_id = Users_TBL.User_ID);

END

我正在使用laravel查询生成器在laravel中调用上述过程:-

DB::select('call Sel_All_Observation_SP()')

上面以数组形式返回结果。

我正在尝试在上述查询中使用where语句:

$observations = DB::select('call Sel_All_Observation_SP()')->where('user_id',1);

返回错误:

Symfony \\组件\\调试\\异常\\ FatalThrowableError(E_ERROR)

调用成员函数where()的数组

我什至尝试通过以下方法从数组转换为集合:-

$observations = collect(DB::select('call Sel_All_Observation_SP()')->where('user_id',1)->get());

返回相同的错误

由于您没有选择表,因此where语句将不起作用。 至于collect ,代码,请尝试稍微更改语法,使其显示为:

$observations = collect(DB::select('call Sel_All_Observation_SP()'))->where('user_id',1);

上面的代码将来自存储过程的数据放入一个集合中。 然后,您可以使用where函数来过滤结果。 无需在末尾添加->get()

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM