我有以下mysql例程存储过程“sel\u all\u observation\u 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 query在laravel中调用上述过程builder:-
DB::select('call Sel_All_Observation_SP()')
以上是作为数组返回的结果。
我想用上面的where语句query:-
$observations = DB::select('call Sel_All_Observation_SP()')->where('user_id',1);
它返回错误:-
symfony\component\debug\exception\fatalthrowableerror(e\ U错误)
调用数组上的成员函数where()
我甚至尝试通过以下方法将数组转换为集合:-
$observations = collect(DB::select('call Sel_All_Observation_SP()')->where('user_id',1)->get());
它返回相同的错误
1条答案
按热度按时间4uqofj5v1#
由于您没有选择表,因此
where
声明行不通。至于collect
,代码,尝试稍微更改语法,使其显示:上面的代码将存储过程中的数据放入一个集合中。然后你可以使用
where
函数来过滤结果。无需添加->get()
最后。