diff options
author | Andrey Andreev <narf@bofh.bg> | 2012-10-22 22:31:10 +0200 |
---|---|---|
committer | Andrey Andreev <narf@bofh.bg> | 2012-10-22 22:31:10 +0200 |
commit | 9f6bdc0b1b9f56997527652a0e1d09a9b233d32e (patch) | |
tree | 3afda46897eeaecf4e19d83b283eabc88d2287fc /system | |
parent | 082aa4025ff5764cf10d429903bf48f66a65ce9e (diff) |
Fix #1913
Diffstat (limited to 'system')
-rw-r--r-- | system/database/DB_result.php | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/system/database/DB_result.php b/system/database/DB_result.php index d44df6c02..e747044d8 100644 --- a/system/database/DB_result.php +++ b/system/database/DB_result.php @@ -251,27 +251,24 @@ class CI_DB_result { /** * Query result. Acts as a wrapper function for the following functions. * - * @param string + * @param mixed * @param string can be "object" or "array" - * @return mixed either a result object or array + * @return mixed */ public 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); - } + is_array($this->row_data) OR $this->row_data = $this->row_array(0); - // array_key_exists() instead of isset() to allow for MySQL NULL values - if (array_key_exists($n, $this->row_data)) + // array_key_exists() instead of isset() to allow for NULL values + if (empty($this->row_data) OR ! array_key_exists($n, $this->row_data)) { - return $this->row_data[$n]; + return NULL; } - // reset the $n variable if the result was not achieved - $n = 0; + + return $this->row_data[$n]; } if ($type === 'object') return $this->row_object($n); |