在Eloquent ORM中有解决方案吗?
我有一个包含父级标识的数组:
Array ( [0] => 87, [1] => 65, ... )
我想选择表PRODUCTS,其中parent_id列等于数组中的任何一个id
流利:
DB::table('PRODUCTS')->whereIn('parent_id', $parent_ids)->get();
Eloquent:
Product::whereIn('parent_id', $parent_ids)->get();
你的数组必须像这样:
$array = array(87, 65, "etc");
Product::whereIn('parent_id', $array)->get();
或者Product::whereIn('parent_id', array(87, 65, "etc"))->get();
get()
结果:Product::whereIn('parent_id', $parent_ids)->get();
- Ludder