Do you use Query Builder Caching? |
(04-06-2016, 01:59 PM)kilishan Wrote: In the Query Builder, you can cache parts of the query to reuse in the following query, as explained in the user guide. Someone recently brought up the idea of getting rid of that for CI4, since the Query Builder is now a standalone class, and they could just clone the object to get another instance to use if they needed, allowing the Query Builder code to be simplified by removing the caching. Sorry for the English, but it's a translation. I hope it's not too late, I'm going to give you a case of use, all my models extend to a class that I believe in core / SCE_model and SCE_Model extends to CI_Model, the case is as follows. When I have to do a GRID to present data to draw, paginate and filter data, what I do is the following, suppose that it is for users the grid that I am going to work on. I have a method in SCE_Model called get_data_grid (); that I use it in all my models $ this-> db-> stop_cache (); ------------------- HAVE THE AMOUNT OF RECORDS -------------------------- ---------------- $ this-> db-> select ('count (*) as total_records'); $ this-> total_records = $ this-> db-> get ($ this-> table_name) -> row () -> total_records; -------------------------------------------------- -------------------------------------------------- ---------------- ------------------------------------ THIS PAGINATING YOU THE GRID -------- --------------------------- $ this-> db-> limit ($ limit, $ start); $ this-> db-> get ($ this-> table_name) -> result (); -------------------------------------------------- -------------------------------------------------- ---------------- So these 2 queries keep the same criteria: where, or_where, where_in, like, or_like, where_in, group_by you know that this is a subject when a grid is made to maintain the pagination and filters. So from my example model users I only do the following $ this-> db-> start_cache (); $ this-> db-> select, where, or_where, where_in, like, or_like, where_in, join .... And so on And atomically the 2 query already has the same criteria $ this-> get_data_grid (); // THIS METHOD IS THE SCE_Model that all the models use and it adapts to the table that I say $ this-> table_name. |
Messages In This Thread |
Do you use Query Builder Caching? - by kilishan - 04-06-2016, 01:59 PM
RE: Do you use Query Builder Caching? - by orionstar - 04-06-2016, 03:56 PM
RE: Do you use Query Builder Caching? - by Narf - 04-07-2016, 09:09 AM
RE: Do you use Query Builder Caching? - by kilishan - 04-07-2016, 09:12 AM
RE: Do you use Query Builder Caching? - by Narf - 04-07-2016, 09:15 AM
RE: Do you use Query Builder Caching? - by vonalbert - 04-07-2016, 09:46 AM
RE: Do you use Query Builder Caching? - by henry.polanco.r - 03-14-2018, 11:55 AM
RE: Do you use Query Builder Caching? - by dave friend - 03-16-2018, 07:31 AM
|