You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's often necessary to filter a result. In ORM you have the option of doing a find() or accessing a relation on an object, in which case you get results immediately, or writing your own methods or using query() to create a custom search.
The structure of ORM at the moment, however, means that the first examples could easily return the same type of object as query() does - one on which you can then run further methods.
e.g.
$posts = Model_Blog::find(1)->posts; // array
$recent_posts = Model_Blog::find(1)->posts->where('posted', '>', \DB::expr('NOW() - INTERVAL 1 WEEK'); // can't do this
It's often necessary to filter a result. In ORM you have the option of doing a
find()
or accessing a relation on an object, in which case you get results immediately, or writing your own methods or usingquery()
to create a custom search.The structure of ORM at the moment, however, means that the first examples could easily return the same type of object as
query()
does - one on which you can then run further methods.e.g.
You can do this -
Further, you could then do
Like you already do, but if you did
it would do it for you. That is to say, an ORM Query object could be iterable by running it and iterating the result.
The text was updated successfully, but these errors were encountered: