How to reuse database query between blocks?
Permalink
Hi.
I have two blocks on the page and both are requesting the same stuff from the DB. How can I reduce the DB calls to one query and use the data in both blocks?
Regards,
Mark
I have two blocks on the page and both are requesting the same stuff from the DB. How can I reduce the DB calls to one query and use the data in both blocks?
Regards,
Mark
You would ideally put the query into a separate model class and load that model into both block controllers.
How would that prevent the DB query to be called twice? Both would instantiate the model what causes the query to be made. Or is a model object only instantiated once per page load?