summaryrefslogtreecommitdiffstats
path: root/system/database/DB_result.php
diff options
context:
space:
mode:
authorDerek Allard <derek.allard@ellislab.com>2008-01-16 22:10:09 +0100
committerDerek Allard <derek.allard@ellislab.com>2008-01-16 22:10:09 +0100
commit39b622db9bda38282a32bb45623da63efe685729 (patch)
tree0d1a1729dc544ebfd1d3dfb11b2ff78759bcf7be /system/database/DB_result.php
parentf4615fec22671262e95d3a852f8b9088314118f2 (diff)
Many new Active Record functions, and another whack of stuff
Diffstat (limited to 'system/database/DB_result.php')
-rw-r--r--system/database/DB_result.php50
1 files changed, 50 insertions, 0 deletions
diff --git a/system/database/DB_result.php b/system/database/DB_result.php
index b438ad1d8..36eddd840 100644
--- a/system/database/DB_result.php
+++ b/system/database/DB_result.php
@@ -34,6 +34,7 @@ class CI_DB_result {
var $result_object = array();
var $current_row = 0;
var $num_rows = 0;
+ var $row_data = NULL;
/**
@@ -118,17 +119,66 @@ class CI_DB_result {
* Query result. Acts as a wrapper function for the following functions.
*
* @access public
+ * @param string
* @param string can be "object" or "array"
* @return mixed either a result object or array
*/
function row($n = 0, $type = 'object')
{
+ if ( ! is_numeric($n))
+ {
+ // We cache the row data for subsequent uses
+ if ( ! is_array($this->row_data))
+ {
+ $this->row_data = $this->row_array(0);
+ }
+
+ if (isset($this->row_data[$n]))
+ {
+ return $this->row_data[$n];
+ }
+ // reset the $n variable if the result was not achieved
+ $n = 0;
+ }
+
return ($type == 'object') ? $this->row_object($n) : $this->row_array($n);
}
// --------------------------------------------------------------------
/**
+ * Assigns an item into a particular column slot
+ *
+ * @access public
+ * @return object
+ */
+ function set_row($key, $value = NULL)
+ {
+ // We cache the row data for subsequent uses
+ if ( ! is_array($this->row_data))
+ {
+ $this->row_data = $this->row_array(0);
+ }
+
+ if (is_array($key))
+ {
+ foreach ($key as $k => $v)
+ {
+ $this->row_data[$k] = $v;
+ }
+
+ return;
+ }
+
+ if ($key != '' AND ! is_null($value))
+ {
+ $this->row_data[$key] = $value;
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Returns a single result row - object version
*
* @access public