summaryrefslogtreecommitdiffstats
path: root/system/database/DB_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/DB_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/DB_result.php')
-rw-r--r--system/database/DB_result.php22
1 files changed, 13 insertions, 9 deletions
diff --git a/system/database/DB_result.php b/system/database/DB_result.php
index ee0b61201..399e45120 100644
--- a/system/database/DB_result.php
+++ b/system/database/DB_result.php
@@ -156,15 +156,9 @@ class CI_DB_result {
$this->_data_seek(0);
$this->custom_result_object[$class_name] = array();
- while ($row = $this->_fetch_object())
+ while ($row = $this->_fetch_object($class_name))
{
- $object = new $class_name();
- foreach ($row as $key => $value)
- {
- $object->$key = $value;
- }
-
- $custom_result_object[$class_name][] = $object;
+ $custom_result_object[$class_name][] = $row;
}
return $this->custom_result_object[$class_name];
@@ -461,11 +455,21 @@ class CI_DB_result {
/**
* Returns an unbuffered row and move pointer to next row
*
+ * @param string 'array', 'object' or a custom class name
* @return mixed either a result object or array
*/
public function unbuffered_row($type = 'object')
{
- return ($type !== 'array') ? $this->_fetch_object() : $this->_fetch_assoc();
+ if ($type === 'array')
+ {
+ return $this->_fetch_assoc();
+ }
+ elseif ($type === 'object')
+ {
+ return $this->_fetch_object();
+ }
+
+ return $this->_fetch_object($type);
}
// --------------------------------------------------------------------