From 78b24bfdaaea0f208802f36730c032e7ec98eb56 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 29 Feb 2012 16:43:57 +0200 Subject: Fix ODBC num_rows() for subdrivers that return -1 --- system/database/drivers/odbc/odbc_result.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'system/database/drivers/odbc/odbc_result.php') 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; } /** -- cgit v1.2.3-24-g4f1b