Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Eloquent raw query in parameter

I have laravel eloquent example query:

DB::select('SELECT * FROM users u WHERE u.id IN :param', ['param' => [1, 2, 3]]);

But it doesn’t work.
How can I bind this array parameter to query.

In symfony I could use ->setParameter(‘param’, Connection::PARAM_INT_ARRAY);
But I dont see option do it the same in Laravel.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Regards.

>Solution :

otherway, You can use a string and a Mark selector insteade of param :

DB::select('SELECT * FROM users u WHERE u.id IN (?)', ['1, 2, 3']);
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading