There is a better query optimization in the CI framework, that is, the database cache optimization
1. Turn on caching
Open $db in application/config.php [' Default '] [' cache_on '] = true;//open $db[' default ' in application/config.php Cachedir '] = './cache ';//and add a writeable cache directory to the corresponding directory cache
2. Open the cache statement in the corresponding query
3. Add the appropriate empty cache
Cache is not automatically deleted only manually//So you can clear the cache in the corresponding add-in DELETE statement//Clear All cache $this->db->cache_delete_all ()//Empty a single cache example.com/ Index.php/blog/comments page, the cache system will put all the generated cache files in a folder named Blog+comments. If you want to delete the corresponding cache file for the example mentioned earlier, you need to execute the following code: */$this->db->cache_delete ('/blog ', ' comments ');
CI Framework Learning VI (database query cache optimization)