Caching in custom database group. - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Caching in custom database group. (/showthread.php?tid=6615) |
Caching in custom database group. - El Forum - 03-05-2008 [eluser]kamilko[/eluser] Hi. I have following case: database config group called 'configuration' and of course an 'default' group. I'm trying to load database 'configuration' without loading 'default' database in library which is loaded in controller constructor. so my library constructor looks like this: Code: function __construct() { my part of configuration group looks like: Code: $db['configuration']['cache_on'] = TRUE; and when I trying load my library I have following error: Quote:Fatal error: Call to a member function cache_off() on a non-object in ...system/database/DB_cache.php on line 58 Obviously '/tmp' dir has access for httpd process and it doesn't matter if I use 'mysql' or 'mysqli' driver. If I place in constructor before loading 'configuration' group following code: Code: $this->obj->load->database(); Caching in custom database group. - El Forum - 03-05-2008 [eluser]Seppo[/eluser] I think cache will only work with the database object assigned to $CI->db. I don't find any note about this in the documentation, and I think this can be easily corrected... On the _cache_init method the Cache object is instantiated (line 1086)... you can pass the database instance to the constructor and replacing the $this->CI->db call for $this->db... something like this database/DB_driver.php - line 1086 Code: $this->CACHE = new CI_DB_Cache; database/DB_cache.php Code: class CI_DB_Cache { I've tested it here and it seems to work =) Caching in custom database group. - El Forum - 03-06-2008 [eluser]kamilko[/eluser] Thank you! I think this should be included in next CI realease. |