Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Problem with multiple query on a model
I have a model with many attributs (id, name, city, zipcode, ...).
If i do this query :
$q = \Model_Pageadherent::query()
->where('zipcode', '=', '97420')
And after this i do :
$adhs = \Model_Pageadherent::query()->where('zipcode', '97420')->get();
My model in $adhs contains just the attribute "id" and "city" because it keep the select('city') in the previous query.
It's normal ? Or a bug ?
Ok i think is the cache. With from_cache(false) it's work.
select() is not really supported in ORM.
ORM caches query results, so if you run a second query for a PK you have already, you get the object from cache back.
Partial selects create incomplete objects (properties missing), which is potentially very dangerous when you start manipulating them (or saving them), and should be avoided.
Thanks for your answer, i understand better!
I blieve that this thread is approprited place for my question.
I'm curious is there a plan is to create standalone cache for such partial-selected objects?
No, there isn't.
But for v2 we're going to completely rewrite the ORM. If you have idea's about features or implementation, create an issue here:
so it can be discussed.
Thanks for your answer!
Add a Comment
It looks like you're new here. If you want to get involved, click one of these buttons!
Apply for Membership
↳ Job Board
↳ Installation & Setup
↳ Tips and Tutorials
↳ Code share
In this Discussion