summaryrefslogtreecommitdiffstats
path: root/system/database
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-02-29 15:43:57 +0100
committerAndrey Andreev <narf@bofh.bg>2012-02-29 15:43:57 +0100
commit78b24bfdaaea0f208802f36730c032e7ec98eb56 (patch)
treece864e02fde6d122d226e76a39bb016c1c88d075 /system/database
parent59910a6a12b27b2b8a2085f206eb2b7e263253ff (diff)
Fix ODBC num_rows() for subdrivers that return -1
Diffstat (limited to 'system/database')
-rw-r--r--system/database/drivers/odbc/odbc_result.php13
1 files changed, 12 insertions, 1 deletions
diff --git a/system/database/drivers/odbc/odbc_result.php b/system/database/drivers/odbc/odbc_result.php
index 320b9327c..e7cbc7af5 100644
--- a/system/database/drivers/odbc/odbc_result.php
+++ b/system/database/drivers/odbc/odbc_result.php
@@ -43,7 +43,18 @@ class CI_DB_odbc_result extends CI_DB_result {
*/
public function num_rows()
{
- return @odbc_num_rows($this->result_id);
+ if ($this->num_rows > 0)
+ {
+ 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)
+ {
+ return $this->num_rows = count($this->result_array());
+ }
+
+ return $this->num_rows;
}
/**