Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
272 views
in Technique[技术] by (71.8m points)

Laravel 4 Eloquent ORM select where - array as parameter

Is solution for this in Eloquent ORM?

I have array with parents idetifiers:

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

And i want select table PRODUCTS where parent_id column = any id in array

question from:https://stackoverflow.com/questions/17605693/laravel-4-eloquent-orm-select-where-array-as-parameter

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Fluent:

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

Eloquent:

Product::whereIn('parent_id', $parent_ids)->get();

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...