summaryrefslogtreecommitdiffstats
path: root/system/database/drivers/odbc/odbc_result.php
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 /system/database/drivers/odbc/odbc_result.php
parent41e46a97a43b0d5080bb9ace1b9326266955ef21 (diff)
Fix issue #129 (ODBC num_rows() returning -1 in some cases)
Diffstat (limited to 'system/database/drivers/odbc/odbc_result.php')
-rw-r--r--system/database/drivers/odbc/odbc_result.php20
1 files changed, 16 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;
}
// --------------------------------------------------------------------