jeudi 12 juillet 2018

`where in` taking only first value in stored procedure mysql

I am stuck with a problem and have been searching for a solution since 6 hours.

I am calling a stored procedure using PHP to fetch tasks of different users by passing a bunch of user IDs. I have the user IDs separated with ,.

$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.'")'));

And the stored procedure has only one simple query like:

select firstname from users where id in (uids)

Here I have declared uids as varchar(255) as IN parameter.

PROBLEM

When I call the function, I get firstname of user id 59. If I hard code the values in SP, like (59,49) I am getting firstname of both the users.

EXPECTED

It should return firstname for both.

Please, please help my guys.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire