A
A
Alexander2017-02-28 09:52:23
Laravel
Alexander, 2017-02-28 09:52:23

Or Where in lavel?

How to query with OR.
We have an ID array, there can be a lot of IDs in the array. Array like:
$prop[$i] = array('id', '=', $n);
And I need to select all fields where id == $n or id == $n1 etc.
Thank you!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nik Gubin, 2017-02-28
@indefpro

$results = DB::table('table_name')
  ->whereIn('id', [$i1, $i2, ..., $in])
  ->get();

Lots of information here: https://laravel.com/docs/5.4/queries#where-clauses
Good luck!

H
hakkol, 2017-02-28
@hakkol

https://laravel.com/docs/5.4/collections#method-wherein

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question