summaryrefslogtreecommitdiffstats
path: root/system/database/drivers/oci8/oci8_result.php
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-07-06 10:57:37 +0200
committerAndrey Andreev <narf@bofh.bg>2012-07-06 10:57:37 +0200
commit9a4f356846daa078c077cbadb227524c857b8f97 (patch)
treebb6b3ee33c3056438149a252a593cae9eed92390 /system/database/drivers/oci8/oci8_result.php
parent9e3a83a65668cc26b685f0b35a4428809435f7c9 (diff)
_fetch_object(), custom_result_object() to utilize PHP's native capability to directly return custom class results
Diffstat (limited to 'system/database/drivers/oci8/oci8_result.php')
-rw-r--r--system/database/drivers/oci8/oci8_result.php21
1 files changed, 18 insertions, 3 deletions
diff --git a/system/database/drivers/oci8/oci8_result.php b/system/database/drivers/oci8/oci8_result.php
index faa295e2a..a2b600e6c 100644
--- a/system/database/drivers/oci8/oci8_result.php
+++ b/system/database/drivers/oci8/oci8_result.php
@@ -167,12 +167,27 @@ class CI_DB_oci8_result extends CI_DB_result {
*
* Returns the result set as an object
*
+ * @param string
* @return object
*/
- protected function _fetch_object()
+ protected function _fetch_object($class_name = 'stdClass')
{
- $id = ($this->curs_id) ? $this->curs_id : $this->stmt_id;
- return oci_fetch_object($id);
+ $row = ($this->curs_id)
+ ? oci_fetch_object($this->curs_id)
+ : oci_fetch_object($this->stmt_id);
+
+ if ($class_name === 'stdClass' OR ! $row)
+ {
+ return $row;
+ }
+
+ $class_name = new $class_name();
+ foreach ($row as $key => $value)
+ {
+ $class_name->$key = $value;
+ }
+
+ return $class_name;
}
// --------------------------------------------------------------------