【发布时间】:2018-12-03 10:36:46
【问题描述】:
我有以下 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());
返回同样的错误
【问题讨论】:
-
死转储时得到了什么? dd(DB::select('call Sel_All_Observation_SP()'));
标签: php mysql laravel stored-procedures eloquent