1 <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
\r
5 * An open source application development framework for PHP 4.3.2 or newer
\r
7 * @package CodeIgniter
\r
8 * @author ExpressionEngine Dev Team
\r
9 * @copyright Copyright (c) 2008, EllisLab, Inc.
\r
10 * @license http://codeigniter.com/user_guide/license.html
\r
11 * @link http://codeigniter.com
\r
12 * @since Version 1.0
\r
16 // ------------------------------------------------------------------------
\r
21 * This class extends the parent result class: CI_DB_result
\r
23 * @category Database
\r
24 * @author ExpressionEngine Dev Team
\r
25 * @link http://codeigniter.com/user_guide/database/
\r
27 class CI_DB_odbc_result extends CI_DB_result {
\r
30 * Number of rows in the result set
\r
37 return @odbc_num_rows($this->result_id);
\r
40 // --------------------------------------------------------------------
\r
43 * Number of fields in the result set
\r
48 function num_fields()
\r
50 return @odbc_num_fields($this->result_id);
\r
53 // --------------------------------------------------------------------
\r
58 * Generates an array of column names
\r
63 function list_fields()
\r
65 $field_names = array();
\r
66 for ($i = 0; $i < $this->num_fields(); $i++)
\r
68 $field_names[] = odbc_field_name($this->result_id, $i);
\r
71 return $field_names;
\r
74 // --------------------------------------------------------------------
\r
79 * Generates an array of objects containing field meta-data
\r
84 function field_data()
\r
87 for ($i = 0; $i < $this->num_fields(); $i++)
\r
89 $F = new stdClass();
\r
90 $F->name = odbc_field_name($this->result_id, $i);
\r
91 $F->type = odbc_field_type($this->result_id, $i);
\r
92 $F->max_length = odbc_field_len($this->result_id, $i);
\r
93 $F->primary_key = 0;
\r
102 // --------------------------------------------------------------------
\r
109 function free_result()
\r
111 if (is_resource($this->result_id))
\r
113 odbc_free_result($this->result_id);
\r
114 $this->result_id = FALSE;
\r
118 // --------------------------------------------------------------------
\r
123 * Moves the internal pointer to the desired offset. We call
\r
124 * this internally before fetching results to make sure the
\r
125 * result set starts at zero
\r
130 function _data_seek($n = 0)
\r
135 // --------------------------------------------------------------------
\r
138 * Result - associative array
\r
140 * Returns the result set as an array
\r
145 function _fetch_assoc()
\r
147 if (function_exists('odbc_fetch_object'))
\r
149 return odbc_fetch_array($this->result_id);
\r
153 return $this->_odbc_fetch_array($this->result_id);
\r
157 // --------------------------------------------------------------------
\r
162 * Returns the result set as an object
\r
167 function _fetch_object()
\r
169 if (function_exists('odbc_fetch_object'))
\r
171 return odbc_fetch_object($this->result_id);
\r
175 return $this->_odbc_fetch_object($this->result_id);
\r
183 * subsititutes the odbc_fetch_object function when
\r
184 * not available (odbc_fetch_object requires unixODBC)
\r
189 function _odbc_fetch_object(& $odbc_result) {
\r
192 if (odbc_fetch_into($odbc_result, $rs)) {
\r
193 foreach ($rs as $k=>$v) {
\r
194 $field_name= odbc_field_name($odbc_result, $k+1);
\r
195 $rs_obj->$field_name = $v;
\r
205 * subsititutes the odbc_fetch_array function when
\r
206 * not available (odbc_fetch_array requires unixODBC)
\r
211 function _odbc_fetch_array(& $odbc_result) {
\r
214 if (odbc_fetch_into($odbc_result, $rs)) {
\r
216 foreach ($rs as $k=>$v) {
\r
217 $field_name= odbc_field_name($odbc_result, $k+1);
\r
218 $rs_assoc[$field_name] = $v;
\r
227 /* End of file odbc_result.php */
\r
228 /* Location: ./system/database/drivers/odbc/odbc_result.php */