CodeIgniter Forums
Cache with custom_row_object - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Cache with custom_row_object (/showthread.php?tid=73801)



Cache with custom_row_object - jfri - 06-07-2019

Hello folks,

I have a question because of the cache. I enabled it in our application and now a query in this format doesn't work anymore:
PHP Code:
$this->CI->db->where('customModelId'$customModelId)->get('custom-table')->row(0'customModel'); 

(We need $this->CI for the session, that's okay like this)

The thing is, I found out that if the data is loaded from the cache, there is no conn_id and no result_id set in the result, which makes perfectly sense. The thing is, if you call row() with a custom model, it will call custom_row_object which will call custom_result_object. In this function there is this if condition:
PHP Code:
elseif ( ! $this->result_id OR $this->num_rows === 0) {
     return array();

This leads to error messages even if the correct data would be loaded. Did anyone else had this problem and has a workaround, which is not in the DB_result.php class? I don't like to mess around in system classes. I use CI 3.1.10.