jeudi 12 mars 2020

How to execute two where conditions in laravel where order_id is same but product_ids are in array

So I have a table ordered_products ordered_products table structure

I have order id and multiple products_id now I want to fetch result based on orders_id and products_id for example

orders_id =10 , products_ids = array(15,20,21,23)

$result = array();

 foreach (products_ids as $value) {
  $result=DB::table('ordered_products')->where('orders__id','=',10)->where('products_id','=',$value)->get();
  }

I executed the query, but I am only getting single row. Please help me execute the query.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire