![]() |
DB_Cache ignores queryvars [PATCH] - 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: DB_Cache ignores queryvars [PATCH] (/showthread.php?tid=11300) |
DB_Cache ignores queryvars [PATCH] - El Forum - 09-03-2008 [eluser]mark17[/eluser] L.S. Using DB_Cache at least in CI 1.6.2 will never work properly when using prepared statements including variables. Code: /** At any time it will result in creating identical cachefilenames for e.g. SELECT * FROM table WHERE field = ?; (? = 1) SELECT * FROM table WHERE field = ?; (? = 2) The system does _not_ pass parsed SQL statements to the cachesystem, therefore reading previously written cachefiles for the same query will result in yet another write since it cannot be read. Writing cachefiles, however, does not suffer from this problem. The calling code: Code: if (FALSE !== ($cache = $this->CACHE->read($sql))) Regards, DB_Cache ignores queryvars [PATCH] - El Forum - 09-03-2008 [eluser]mark17[/eluser] A quick patch for this problem is switching two sequentiel codeblocks in DB_Driver.php starting at line #270; OLD CODE: Code: // Is query caching enabled? If the query is a "read type" PATCH CODE: Code: // Compile binds if needed This will parse the prepared statement _before_ attempting to compile a filename in DB_Cache itself. I cannot understand that this has been around for quite some time without anyone noticing. Of course, this old behaviour will never surface in altering the state of the data but will result in loss in performance when relying on it. Please submit this patch in future versions. DB_Cache ignores queryvars [PATCH] - El Forum - 10-08-2008 [eluser]mark17[/eluser] L.S. The problem above was reported over a month ago with no form of recognision of whatsoever. Is this, as it's not uncommon, be dismissed yet again? Regards, |