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_oci8_result extends CI_DB_result {
\r
34 * Number of rows in the result set.
\r
36 * Oracle doesn't have a graceful way to retun the number of rows
\r
37 * so we have to use what amounts to a hack.
\r
45 $rowcount = count($this->result_array());
\r
46 @ociexecute($this->stmt_id);
\r
50 @ociexecute($this->curs_id);
\r
56 // --------------------------------------------------------------------
\r
59 * Number of fields in the result set
\r
64 function num_fields()
\r
66 $count = @ocinumcols($this->stmt_id);
\r
68 // if we used a limit we subtract it
\r
69 if ($this->limit_used)
\r
71 $count = $count - 1;
\r
77 // --------------------------------------------------------------------
\r
82 * Generates an array of column names
\r
87 function list_fields()
\r
89 $field_names = array();
\r
90 $fieldCount = $this->num_fields();
\r
91 for ($c = 1; $c <= $fieldCount; $c++)
\r
93 $field_names[] = ocicolumnname($this->stmt_id, $c);
\r
95 return $field_names;
\r
98 // --------------------------------------------------------------------
\r
103 * Generates an array of objects containing field meta-data
\r
108 function field_data()
\r
111 $fieldCount = $this->num_fields();
\r
112 for ($c = 1; $c <= $fieldCount; $c++)
\r
114 $F = new stdClass();
\r
115 $F->name = ocicolumnname($this->stmt_id, $c);
\r
116 $F->type = ocicolumntype($this->stmt_id, $c);
\r
117 $F->max_length = ocicolumnsize($this->stmt_id, $c);
\r
125 // --------------------------------------------------------------------
\r
132 function free_result()
\r
134 if (is_resource($this->result_id))
\r
136 ocifreestatement($this->result_id);
\r
137 $this->result_id = FALSE;
\r
141 // --------------------------------------------------------------------
\r
144 * Result - associative array
\r
146 * Returns the result set as an array
\r
151 function _fetch_assoc(&$row)
\r
153 $id = ($this->curs_id) ? $this->curs_id : $this->stmt_id;
\r
155 return ocifetchinto($id, $row, OCI_ASSOC + OCI_RETURN_NULLS);
\r
158 // --------------------------------------------------------------------
\r
163 * Returns the result set as an object
\r
168 function _fetch_object()
\r
172 // If PHP 5 is being used we can fetch an result object
\r
173 if (function_exists('oci_fetch_object'))
\r
175 $id = ($this->curs_id) ? $this->curs_id : $this->stmt_id;
\r
177 return @oci_fetch_object($id);
\r
180 // If PHP 4 is being used we have to build our own result
\r
181 foreach ($this->result_array() as $key => $val)
\r
183 $obj = new stdClass();
\r
184 if (is_array($val))
\r
186 foreach ($val as $k => $v)
\r
202 // --------------------------------------------------------------------
\r
205 * Query result. "array" version.
\r
210 function result_array()
\r
212 if (count($this->result_array) > 0)
\r
214 return $this->result_array;
\r
217 // oracle's fetch functions do not return arrays.
\r
218 // The information is returned in reference parameters
\r
220 while ($this->_fetch_assoc($row))
\r
222 $this->result_array[] = $row;
\r
225 return $this->result_array;
\r
228 // --------------------------------------------------------------------
\r
233 * Moves the internal pointer to the desired offset. We call
\r
234 * this internally before fetching results to make sure the
\r
235 * result set starts at zero
\r
240 function _data_seek($n = 0)
\r
242 return FALSE; // Not needed
\r
248 /* End of file oci8_result.php */
\r
249 /* Location: ./system/database/drivers/oci8/oci8_result.php */