Laravel 4 Eloquent ORM select where - array as parameter

后端 未结 2 2043
梦毁少年i
梦毁少年i 2020-12-13 12:44

Is solution for this in Eloquent ORM?

I have array with parents idetifiers:

Array ( [0] => 87,  [1] => 65, ... )

And i want s

相关标签:
2条回答
  • 2020-12-13 13:26

    Your array must be like this :

    $array = array(87, 65, "etc");
    Product::whereIn('parent_id', $array)->get();
    

    or

    Product::whereIn('parent_id', array(87, 65, "etc"))->get();
    
    0 讨论(0)
  • 2020-12-13 13:47

    Fluent:

    DB::table('PRODUCTS')->whereIn('parent_id', $parent_ids)->get();
    

    Eloquent:

    Product::whereIn('parent_id', $parent_ids)->get();
    
    0 讨论(0)
提交回复
热议问题