summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-03-01 14:15:31 +0100
committerAndrey Andreev <narf@bofh.bg>2012-03-01 14:15:31 +0100
commitef795ac23320c4636152af03c8600f2115f1e6e3 (patch)
tree9badf8550326b3114b08b015ab045b8c09fcd825
parent41e46a97a43b0d5080bb9ace1b9326266955ef21 (diff)
Fix issue #129 (ODBC num_rows() returning -1 in some cases)
-rw-r--r--system/database/drivers/odbc/odbc_result.php20
-rw-r--r--user_guide_src/source/changelog.rst1
2 files changed, 17 insertions, 4 deletions
diff --git a/system/database/drivers/odbc/odbc_result.php b/system/database/drivers/odbc/odbc_result.php
index bfd6949eb..572e110ca 100644
--- a/system/database/drivers/odbc/odbc_result.php
+++ b/system/database/drivers/odbc/odbc_result.php
@@ -38,15 +38,27 @@
*/
class CI_DB_odbc_result extends CI_DB_result {
+ public $num_rows;
+
/**
* Number of rows in the result set
*
- * @access public
- * @return integer
+ * @return int
*/
- function num_rows()
+ public function num_rows()
{
- return @odbc_num_rows($this->result_id);
+ if (is_int($this->num_rows))
+ {
+ return $this->num_rows;
+ }
+
+ // Work-around for ODBC subdrivers that don't support num_rows()
+ if (($this->num_rows = @odbc_num_rows($this->result_id)) === -1)
+ {
+ $this->num_rows = count($this->result_array());
+ }
+
+ return $this->num_rows;
}
// --------------------------------------------------------------------
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index bd9776ce1..d43291d63 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -114,6 +114,7 @@ Bug fixes for 3.0
- Fixed a bug (#177) - CI_Form_validation::set_value() didn't set the default value if POST data is NULL.
- Fixed a bug (#68, #414) - Oracle's escape_str() didn't properly escape LIKE wild characters.
- Fixed a bug (#81) - ODBC's list_fields() and field_data() methods skipped the first column due to odbc_field_*() functions' index starting at 1 instead of 0.
+- Fixed a bug (#129) - ODBC's num_rows() returned -1 in some cases, due to not all subdrivers supporting the odbc_num_rows() function.
Version 2.1.1
=============