![]() |
Issue with Custom DB Result Object with DB Cache Enabled - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6) +--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17) +--- Thread: Issue with Custom DB Result Object with DB Cache Enabled (/showthread.php?tid=87903) |
Issue with Custom DB Result Object with DB Cache Enabled - Bunny458 - 06-16-2023 Hi, I am using the CI Query Builder to execute a simple SQL query as follows: PHP Code: $query = $this->db->query($sql, array($binds)); The above works without any issues and returns the expected array of result objects of 'My_class_entity'. However, as soon as I enable DB query caching I am unable to generate a result with a custom result object. For example using the following code: PHP Code: $this->db->cache_on(); The result of $query->result('my_class_entity') in this case is simply an empty array. However if I return $query->result() or explicitly $query->result_array() or $query->result_object() the expected data is returned as either an array or array of StdClass objects. As far as I can tell there is no caching issue itself as the cache file is correctly generated, no caching related errors appear in the log and returning a generic $query->result() works fine. I've attempted modifying the query component to: $query = $this->db->query($sql, array($binds), true); although this doesn't seem to have any effect and the CI documentation for 3.X is not clear on what this truly does. Is this a limitation in CI that prevents a custom object result being returned with query caching, or am I missing something here? Thanks. RE: Issue with Custom DB Result Object with DB Cache Enabled - InsiteFX - 06-16-2023 CodeIgniter 4 User Guide - Custom Result Objects |