klik
3 months ago
1267
20
General

Array paremters in WHERE IN condition

Posted 3 months ago by klik

Hi. I'm very surprise my code bellow doesn't work .

$raw = DB::SELECT("

            SELECT
               *
              FROM places p
              WHERE p.id IN :placesId
            ",[

            'placesId' => [1,2,3],

        ]);

I receive this error:

"Array to string conversion (SQL: SELECT * FROM places p WHERE p.id IN :placesId )"

Why it doesn't work. Most of time I use Symfony and there this query always was working so ho to write it in Laravel?

If placesId is a array and IN expect array so what is wrong?

Regards

Please sign in or create an account to participate in this conversation.