From 3afcaf7e12077bcb7811bd53adb6e48d27c7f5e5 Mon Sep 17 00:00:00 2001 From: Deon George Date: Thu, 8 Oct 2015 21:25:36 +1100 Subject: [PATCH] Disable reload on wakeup for cached queries --- classes/Kohana/Database/DB2/Result.php | 5 +++-- classes/ORM/DB2.php | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/classes/Kohana/Database/DB2/Result.php b/classes/Kohana/Database/DB2/Result.php index 219c9bb..09b04f2 100644 --- a/classes/Kohana/Database/DB2/Result.php +++ b/classes/Kohana/Database/DB2/Result.php @@ -62,12 +62,13 @@ class Kohana_Database_DB2_Result extends Database_Result { } elseif (is_string($this->_as_object)) { - throw new Kohana_Exception('This configuration is not tested for caching'); $o = new $this->_as_object; // Return an object of given class name // @todo This doesnt have $this->_loaded = $this->_valid = TRUE; - return $o->values(db2_fetch_assoc($this->_result)); + return $o->values(isset($this->_internal_data[$this->_internal_row]) + ? $this->_internal_data[$this->_internal_row] + : ($this->_internal_data[$this->_internal_row] = db2_fetch_assoc($this->_result))); } else { diff --git a/classes/ORM/DB2.php b/classes/ORM/DB2.php index 68560b0..731c896 100644 --- a/classes/ORM/DB2.php +++ b/classes/ORM/DB2.php @@ -32,6 +32,9 @@ abstract class ORM_DB2 extends ORM { $this->_table_name = strtoupper($this->_table_name); parent::_initialize(); + + // If we are caching queries, we cannot reload on wakeup. + $this->_reload_on_wakeup = ! $this->_db->caching(); } } ?>