1 <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
5 * An open source application development framework for PHP 5.1.6 or newer
8 * @author ExpressionEngine Dev Team
9 * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
10 * @license http://codeigniter.com/user_guide/license.html
11 * @link http://codeigniter.com
16 // ------------------------------------------------------------------------
21 * This class extends the parent result class: CI_DB_result
24 * @author ExpressionEngine Dev Team
25 * @link http://codeigniter.com/user_guide/database/
27 class CI_DB_oci8_result extends CI_DB_result {
34 * Number of rows in the result set.
36 * Oracle doesn't have a graceful way to retun the number of rows
37 * so we have to use what amounts to a hack.
45 $rowcount = count($this->result_array());
46 @ociexecute($this->stmt_id);
50 @ociexecute($this->curs_id);
56 // --------------------------------------------------------------------
59 * Number of fields in the result set
66 $count = @ocinumcols($this->stmt_id);
68 // if we used a limit we subtract it
69 if ($this->limit_used)
77 // --------------------------------------------------------------------
82 * Generates an array of column names
87 function list_fields()
89 $field_names = array();
90 $fieldCount = $this->num_fields();
91 for ($c = 1; $c <= $fieldCount; $c++)
93 $field_names[] = ocicolumnname($this->stmt_id, $c);
98 // --------------------------------------------------------------------
103 * Generates an array of objects containing field meta-data
108 function field_data()
111 $fieldCount = $this->num_fields();
112 for ($c = 1; $c <= $fieldCount; $c++)
115 $F->name = ocicolumnname($this->stmt_id, $c);
116 $F->type = ocicolumntype($this->stmt_id, $c);
117 $F->max_length = ocicolumnsize($this->stmt_id, $c);
125 // --------------------------------------------------------------------
132 function free_result()
134 if (is_resource($this->result_id))
136 ocifreestatement($this->result_id);
137 $this->result_id = FALSE;
141 // --------------------------------------------------------------------
144 * Result - associative array
146 * Returns the result set as an array
151 function _fetch_assoc(&$row)
153 $id = ($this->curs_id) ? $this->curs_id : $this->stmt_id;
155 return ocifetchinto($id, $row, OCI_ASSOC + OCI_RETURN_NULLS);
158 // --------------------------------------------------------------------
163 * Returns the result set as an object
168 function _fetch_object()
172 // If PHP 5 is being used we can fetch an result object
173 if (function_exists('oci_fetch_object'))
175 $id = ($this->curs_id) ? $this->curs_id : $this->stmt_id;
177 return @oci_fetch_object($id);
180 // If PHP 4 is being used we have to build our own result
181 foreach ($this->result_array() as $key => $val)
183 $obj = new stdClass();
186 foreach ($val as $k => $v)
202 // --------------------------------------------------------------------
205 * Query result. "array" version.
210 function result_array()
212 if (count($this->result_array) > 0)
214 return $this->result_array;
217 // oracle's fetch functions do not return arrays.
218 // The information is returned in reference parameters
220 while ($this->_fetch_assoc($row))
222 $this->result_array[] = $row;
225 return $this->result_array;
228 // --------------------------------------------------------------------
233 * Moves the internal pointer to the desired offset. We call
234 * this internally before fetching results to make sure the
235 * result set starts at zero
240 function _data_seek($n = 0)
242 return FALSE; // Not needed
248 /* End of file oci8_result.php */
249 /* Location: ./system/database/drivers/oci8/oci8_result.php */