lundi 23 mai 2016

Cannot use mysql function IN in laravel db statement

Im having a problem when using the IN function of MySQL in a Laravel 5.2 DB Statement. Here is the example:

$str_array = implode(",",$array_reservations);
$sql_result = DB::select("
            select r.id,r.people,r.date,r.status,p.alias,u.name,p.profile
            from  reservations r inner join places p on p.id = r.place_id 
            inner join  users u on u.id = r.user_id
            where r.id in(?)
            order by r.date desc
            ", [$str_array]);

But in the result I just get the result of the first reservation of the array.

The length of the array will be always variable.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/20rqoju
via IFTTT

Aucun commentaire:

Enregistrer un commentaire