summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-05-24 21:13:06 +0200
committerAndrey Andreev <narf@bofh.bg>2012-05-24 21:13:06 +0200
commit55d3ad4faf2727b900832884e7c219076a255b66 (patch)
treef40c6089ccc1742ec5efd2961ed040caed4361f4
parent470805b12a8a25faddc9caafe573c15dbd89f8ed (diff)
Fix issue #121
-rw-r--r--system/database/DB_result.php16
-rw-r--r--system/database/drivers/oci8/oci8_result.php16
-rw-r--r--system/database/drivers/sqlite3/sqlite3_result.php16
-rw-r--r--user_guide_src/source/changelog.rst1
4 files changed, 26 insertions, 23 deletions
diff --git a/system/database/DB_result.php b/system/database/DB_result.php
index 690734b08..334e08c72 100644
--- a/system/database/DB_result.php
+++ b/system/database/DB_result.php
@@ -242,7 +242,7 @@ class CI_DB_result {
$result = $this->custom_result_object($type);
if (count($result) === 0)
{
- return $result;
+ return NULL;
}
if ($n != $this->current_row && isset($result[$n]))
@@ -253,6 +253,8 @@ class CI_DB_result {
return $result[$this->current_row];
}
+ // --------------------------------------------------------------------
+
/**
* Returns a single result row - object version
*
@@ -263,7 +265,7 @@ class CI_DB_result {
$result = $this->result_object();
if (count($result) === 0)
{
- return $result;
+ return NULL;
}
if ($n != $this->current_row && isset($result[$n]))
@@ -286,7 +288,7 @@ class CI_DB_result {
$result = $this->result_array();
if (count($result) === 0)
{
- return $result;
+ return NULL;
}
if ($n != $this->current_row && isset($result[$n]))
@@ -307,7 +309,7 @@ class CI_DB_result {
public function first_row($type = 'object')
{
$result = $this->result($type);
- return (count($result) === 0) ? $result : $result[0];
+ return (count($result) === 0) ? NULL : $result[0];
}
// --------------------------------------------------------------------
@@ -320,7 +322,7 @@ class CI_DB_result {
public function last_row($type = 'object')
{
$result = $this->result($type);
- return (count($result) === 0) ? $result : $result[count($result) - 1];
+ return (count($result) === 0) ? NULL : $result[count($result) - 1];
}
// --------------------------------------------------------------------
@@ -335,7 +337,7 @@ class CI_DB_result {
$result = $this->result($type);
if (count($result) === 0)
{
- return $result;
+ return NULL;
}
if (isset($result[$this->current_row + 1]))
@@ -358,7 +360,7 @@ class CI_DB_result {
$result = $this->result($type);
if (count($result) === 0)
{
- return $result;
+ return NULL;
}
if (isset($result[$this->current_row - 1]))
diff --git a/system/database/drivers/oci8/oci8_result.php b/system/database/drivers/oci8/oci8_result.php
index 7b05e0a43..6fb6c81f1 100644
--- a/system/database/drivers/oci8/oci8_result.php
+++ b/system/database/drivers/oci8/oci8_result.php
@@ -419,7 +419,7 @@ class CI_DB_oci8_result extends CI_DB_result {
OR $n < $this->current_row)
{
// No such row exists
- return array();
+ return NULL;
}
// Get the next row index that would actually need to be fetched
@@ -460,7 +460,7 @@ class CI_DB_oci8_result extends CI_DB_result {
$this->num_rows = 0;
}
- return array();
+ return NULL;
}
$this->current_row = $n;
@@ -507,7 +507,7 @@ class CI_DB_oci8_result extends CI_DB_result {
return (object) $row;
}
- return array();
+ return NULL;
}
// --------------------------------------------------------------------
@@ -539,19 +539,19 @@ class CI_DB_oci8_result extends CI_DB_result {
}
else
{
- return array();
+ return NULL;
}
}
elseif ( ! class_exists($class_name)) // No such class exists
{
- return array();
+ return NULL;
}
$row = $this->row_array($n);
- // An array would mean that the row doesn't exist
- if (is_array($row))
+ // A non-array would mean that the row doesn't exist
+ if ( ! is_array($row))
{
- return $row;
+ return NULL;
}
// Convert to the desired class and return
diff --git a/system/database/drivers/sqlite3/sqlite3_result.php b/system/database/drivers/sqlite3/sqlite3_result.php
index d83d6b2cd..946b36557 100644
--- a/system/database/drivers/sqlite3/sqlite3_result.php
+++ b/system/database/drivers/sqlite3/sqlite3_result.php
@@ -386,7 +386,7 @@ class CI_DB_sqlite3_result extends CI_DB_result {
OR count($this->result_array) > 0 OR $n < $this->current_row)
{
// No such row exists
- return array();
+ return NULL;
}
// Get the next row index that would actually need to be fetched
@@ -427,7 +427,7 @@ class CI_DB_sqlite3_result extends CI_DB_result {
$this->num_rows = 0;
}
- return array();
+ return NULL;
}
$this->current_row = $n;
@@ -469,7 +469,7 @@ class CI_DB_sqlite3_result extends CI_DB_result {
return (object) $row;
}
- return array();
+ return NULL;
}
// --------------------------------------------------------------------
@@ -501,19 +501,19 @@ class CI_DB_sqlite3_result extends CI_DB_result {
}
else
{
- return array();
+ return NULL;
}
}
elseif ( ! class_exists($class_name)) // No such class exists
{
- return array();
+ return NULL;
}
$row = $this->row_array($n);
- // An array would mean that the row doesn't exist
- if (is_array($row))
+ // A non-array would mean that the row doesn't exist
+ if ( ! is_array($row))
{
- return $row;
+ return NULL;
}
// Convert to the desired class and return
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 8ee224fc6..67f1271f1 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -216,6 +216,7 @@ Bug fixes for 3.0
- Fixed a bug (#1349) - get_extension() in the :doc:`File Uploading Library <libraries/file_uploading>` returned the original filename when it didn't have an actual extension.
- Fixed a bug (#1273) - E_NOTICE being generated by :doc:`Query Builder <database/query_builder>`'s set_update_batch() method.
- Fixed a bug (#44, #110) - :doc:`Upload library <libraries/file_uploading>`'s clean_file_name() method didn't clear '!' and '#' characters.
+- Fixed a bug (#121) - ``CI_DB_result::row()`` returned an array when there's no actual result to be returned.
Version 2.1.1
=============