diff options
Diffstat (limited to 'system/database/DB_result.php')
-rw-r--r-- | system/database/DB_result.php | 50 |
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
|