summaryrefslogtreecommitdiffstats
path: root/system/database/drivers/odbc/odbc_result.php
diff options
context:
space:
mode:
Diffstat (limited to 'system/database/drivers/odbc/odbc_result.php')
-rw-r--r--system/database/drivers/odbc/odbc_result.php111
1 files changed, 56 insertions, 55 deletions
diff --git a/system/database/drivers/odbc/odbc_result.php b/system/database/drivers/odbc/odbc_result.php
index bfd6949eb..db3576d35 100644
--- a/system/database/drivers/odbc/odbc_result.php
+++ b/system/database/drivers/odbc/odbc_result.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* ODBC Result Class
*
@@ -41,15 +39,23 @@ class CI_DB_odbc_result extends CI_DB_result {
/**
* 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 ($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;
+ }
/**
* Number of fields in the result set
@@ -116,9 +122,9 @@ class CI_DB_odbc_result extends CI_DB_result {
/**
* Free the result
*
- * @return null
+ * @return void
*/
- function free_result()
+ public function free_result()
{
if (is_resource($this->result_id))
{
@@ -132,15 +138,15 @@ class CI_DB_odbc_result extends CI_DB_result {
/**
* Data Seek
*
- * Moves the internal pointer to the desired offset. We call
+ * Moves the internal pointer to the desired offset. We call
* this internally before fetching results to make sure the
* result set starts at zero
*
- * @access private
* @return array
*/
- function _data_seek($n = 0)
+ protected function _data_seek($n = 0)
{
+ // Not supported
return FALSE;
}
@@ -151,19 +157,13 @@ class CI_DB_odbc_result extends CI_DB_result {
*
* Returns the result set as an array
*
- * @access private
* @return array
*/
- function _fetch_assoc()
+ protected function _fetch_assoc()
{
- if (function_exists('odbc_fetch_object'))
- {
- return odbc_fetch_array($this->result_id);
- }
- else
- {
- return $this->_odbc_fetch_array($this->result_id);
- }
+ return function_exists('odbc_fetch_array')
+ ? odbc_fetch_array($this->result_id)
+ : $this->_odbc_fetch_array($this->result_id);
}
// --------------------------------------------------------------------
@@ -173,40 +173,38 @@ class CI_DB_odbc_result extends CI_DB_result {
*
* Returns the result set as an object
*
- * @access private
* @return object
*/
- function _fetch_object()
+ protected function _fetch_object()
{
- if (function_exists('odbc_fetch_object'))
- {
- return odbc_fetch_object($this->result_id);
- }
- else
- {
- return $this->_odbc_fetch_object($this->result_id);
- }
+ return function_exists('odbc_fetch_object')
+ ? odbc_fetch_object($this->result_id)
+ : $this->_odbc_fetch_object($this->result_id);
}
-
/**
* Result - object
*
* subsititutes the odbc_fetch_object function when
* not available (odbc_fetch_object requires unixODBC)
*
- * @access private
* @return object
*/
- function _odbc_fetch_object(& $odbc_result) {
+ private function _odbc_fetch_object(& $odbc_result)
+ {
$rs = array();
- $rs_obj = FALSE;
- if (odbc_fetch_into($odbc_result, $rs)) {
- foreach ($rs as $k=>$v) {
- $field_name= odbc_field_name($odbc_result, $k+1);
- $rs_obj->$field_name = $v;
- }
+ if ( ! odbc_fetch_into($odbc_result, $rs))
+ {
+ return FALSE;
+ }
+
+ $rs_obj = new stdClass();
+ foreach ($rs as $k => $v)
+ {
+ $field_name = odbc_field_name($odbc_result, $k+1);
+ $rs_obj->$field_name = $v;
}
+
return $rs_obj;
}
@@ -217,24 +215,27 @@ class CI_DB_odbc_result extends CI_DB_result {
* subsititutes the odbc_fetch_array function when
* not available (odbc_fetch_array requires unixODBC)
*
- * @access private
* @return array
*/
- function _odbc_fetch_array(& $odbc_result) {
+ private function _odbc_fetch_array(& $odbc_result)
+ {
$rs = array();
- $rs_assoc = FALSE;
- if (odbc_fetch_into($odbc_result, $rs)) {
- $rs_assoc=array();
- foreach ($rs as $k=>$v) {
- $field_name= odbc_field_name($odbc_result, $k+1);
- $rs_assoc[$field_name] = $v;
- }
+ if ( ! odbc_fetch_into($odbc_result, $rs))
+ {
+ return FALSE;
}
+
+ $rs_assoc = array();
+ foreach ($rs as $k => $v)
+ {
+ $field_name = odbc_field_name($odbc_result, $k+1);
+ $rs_assoc[$field_name] = $v;
+ }
+
return $rs_assoc;
}
}
-
/* End of file odbc_result.php */
/* Location: ./system/database/drivers/odbc/odbc_result.php */