xXx_HAWK:
私は、テーブルordered_products持っているので、ordered_productsテーブル構造を
私は注文IDと複数のproducts_idを持っている今、私は、例えばorders_idとproducts_idに基づいて結果を取得したいです
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();
}
私は、クエリを実行しますが、私は1行だけ取得しています。私は、クエリを実行して助けてください。
ラケッシュJakhar:
あなたは使うべきwhere
ORDER_IDためとwhereIn
product_idsのために
$result = DB::table('ordered_products')
->where('orders__id',10)
->whereIn('products_id', $products_ids)
->get();