我被一个问题困住了,从6个小时以来一直在寻找解决办法。
我使用PHP调用一个存储过程,通过传递一组用户id来获取不同用户的任务。
,
.
$user_id_string = "59,49"; // The user IDs have been converted as string using implode function on an array.
$d = DB::select(DB::raw('call fetch_tasks("'.$user_id_string.'")'));
存储过程只有一个简单的查询,如:
select firstname from users where id in (uids)
在这里,我在参数中声明uid为varchar(255)。
问题
当我调用函数时,我得到
firstname
预期
它应该会回来
名字
两者兼而有之。
拜托,帮帮我的人。
更新1:
Hard coded:
CREATE DEFINER=`root`@`localhost` PROCEDURE `fetch_tasks`(IN `cur_lat` VARCHAR(255), IN `cur_lng` VARCHAR(255), IN `uids` VARCHAR(255)) NOT DETERMINISTIC NO SQL SQL SECURITY DEFINER SELECT id, firstname from users where id in (59,49)
By passing variable:
CREATE DEFINER=`root`@`localhost` PROCEDURE `fetch_tasks`(IN `cur_lat` VARCHAR(255), IN `cur_lng` VARCHAR(255), IN `uids` VARCHAR(255)) NOT DETERMINISTIC NO SQL SQL SECURITY DEFINER SELECT id, firstname from users where id in (uids)