From 9f6bdc0b1b9f56997527652a0e1d09a9b233d32e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 22 Oct 2012 23:31:10 +0300 Subject: Fix #1913 --- system/database/DB_result.php | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'system') 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); -- cgit v1.2.3-24-g4f1b