123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218 |
- <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
- /**
- * CodeIgniter
- *
- * An open source application development framework for PHP 5.1.6 or newer
- *
- * @package CodeIgniter
- * @author EllisLab Dev Team
- * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc.
- * @copyright Copyright (c) 2014 - 2015, British Columbia Institute of Technology (http://bcit.ca/)
- * @license http://codeigniter.com/user_guide/license.html
- * @link http://codeigniter.com
- * @since Version 1.0
- * @filesource
- */
- // ------------------------------------------------------------------------
- /**
- * oci8 Result Class
- *
- * This class extends the parent result class: CI_DB_result
- *
- * @category Database
- * @author EllisLab Dev Team
- * @link http://codeigniter.com/user_guide/database/
- */
- class CI_DB_oci8_result extends CI_DB_result {
- public $stmt_id;
- public $curs_id;
- public $limit_used;
- /**
- * Number of rows in the result set.
- *
- * Oracle doesn't have a graceful way to retun the number of rows
- * so we have to use what amounts to a hack.
- *
- * @return integer
- */
- public function num_rows()
- {
- if ($this->num_rows === 0 && count($this->result_array()) > 0)
- {
- $this->num_rows = count($this->result_array());
- @oci_execute($this->stmt_id, OCI_DEFAULT);
- if ($this->curs_id)
- {
- @oci_execute($this->curs_id, OCI_DEFAULT);
- }
- }
- return $this->num_rows;
- }
- // --------------------------------------------------------------------
- /**
- * Number of fields in the result set
- *
- * @access public
- * @return integer
- */
- public function num_fields()
- {
- $count = @oci_num_fields($this->stmt_id);
- // if we used a limit we subtract it
- if ($this->limit_used)
- {
- $count = $count - 1;
- }
- return $count;
- }
- // --------------------------------------------------------------------
- /**
- * Fetch Field Names
- *
- * Generates an array of column names
- *
- * @access public
- * @return array
- */
- public function list_fields()
- {
- $field_names = array();
- for ($c = 1, $fieldCount = $this->num_fields(); $c <= $fieldCount; $c++)
- {
- $field_names[] = oci_field_name($this->stmt_id, $c);
- }
- return $field_names;
- }
- // --------------------------------------------------------------------
- /**
- * Field data
- *
- * Generates an array of objects containing field meta-data
- *
- * @access public
- * @return array
- */
- public function field_data()
- {
- $retval = array();
- for ($c = 1, $fieldCount = $this->num_fields(); $c <= $fieldCount; $c++)
- {
- $F = new stdClass();
- $F->name = oci_field_name($this->stmt_id, $c);
- $F->type = oci_field_type($this->stmt_id, $c);
- $F->max_length = oci_field_size($this->stmt_id, $c);
- $retval[] = $F;
- }
- return $retval;
- }
- // --------------------------------------------------------------------
- /**
- * Free the result
- *
- * @return null
- */
- public function free_result()
- {
- if (is_resource($this->result_id))
- {
- oci_free_statement($this->result_id);
- $this->result_id = FALSE;
- }
- }
- // --------------------------------------------------------------------
- /**
- * Result - associative array
- *
- * Returns the result set as an array
- *
- * @access protected
- * @return array
- */
- protected function _fetch_assoc()
- {
- $id = ($this->curs_id) ? $this->curs_id : $this->stmt_id;
- return oci_fetch_assoc($id);
- }
- // --------------------------------------------------------------------
- /**
- * Result - object
- *
- * Returns the result set as an object
- *
- * @access protected
- * @return object
- */
- protected function _fetch_object()
- {
- $id = ($this->curs_id) ? $this->curs_id : $this->stmt_id;
- return @oci_fetch_object($id);
- }
- // --------------------------------------------------------------------
- /**
- * Query result. "array" version.
- *
- * @access public
- * @return array
- */
- public function result_array()
- {
- if (count($this->result_array) > 0)
- {
- return $this->result_array;
- }
- $row = NULL;
- while ($row = $this->_fetch_assoc())
- {
- $this->result_array[] = $row;
- }
- return $this->result_array;
- }
- // --------------------------------------------------------------------
- /**
- * Data Seek
- *
- * 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 protected
- * @return array
- */
- protected function _data_seek($n = 0)
- {
- return FALSE; // Not needed
- }
- }
- /* End of file oci8_result.php */
- /* Location: ./system/database/drivers/oci8/oci8_result.php */
|