diff options
author | admin <devnull@localhost> | 2006-09-24 20:05:17 +0200 |
---|---|---|
committer | admin <devnull@localhost> | 2006-09-24 20:05:17 +0200 |
commit | 7b613c7000a496fe0e4f9152ee8937d06eba2301 (patch) | |
tree | a99e2d55c859367324cec7d0f5739d7bf9a096df /system/database/drivers/oci8/oci8_result.php | |
parent | b2ab51b432e4de4aeb551ca17cba323ad729f406 (diff) |
Adding database folder
Diffstat (limited to 'system/database/drivers/oci8/oci8_result.php')
-rw-r--r-- | system/database/drivers/oci8/oci8_result.php | 207 |
1 files changed, 207 insertions, 0 deletions
diff --git a/system/database/drivers/oci8/oci8_result.php b/system/database/drivers/oci8/oci8_result.php new file mode 100644 index 000000000..d2354a1c6 --- /dev/null +++ b/system/database/drivers/oci8/oci8_result.php @@ -0,0 +1,207 @@ +<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); +/** + * Code Igniter + * + * An open source application development framework for PHP 4.3.2 or newer + * + * @package CodeIgniter + * @author Rick Ellis + * @copyright Copyright (c) 2006, pMachine, Inc. + * @license http://www.codeignitor.com/user_guide/license.html + * @link http://www.codeigniter.com + * @since Version 1.0 + * @filesource + */ + +// ------------------------------------------------------------------------ + +/** + * oci8 Result Class + * + * This class extends the parent result class: CI_DB_result + * + * @category Database + * @author Rick Ellis + * @link http://www.codeigniter.com/user_guide/database/ + */ +class CI_DB_oci8_result extends CI_DB_result { + + var $stmt_id; + var $curs_id; + var $limit_used; + + /** + * Number of rows in the result set + * + * @access public + * @return integer + */ + function num_rows() + { + // get the results, count them, + // rerun query - otherwise we + // won't have data after calling + // num_rows() + $this->result_array(); + $rowcount = count($this->result_array); + @ociexecute($this->stmt_id); + if ($this->curs_id) + { + @ociexecute($this->curs_id); + } + return $rowcount; + } + + // -------------------------------------------------------------------- + + /** + * Number of fields in the result set + * + * @access public + * @return integer + */ + function num_fields() + { + $count = @ocinumcols($this->stmt_id); + + // if we used a limit, we added a field, + // subtract it out + if ($this->limit_used) + { + $count = $count - 1; + } + + return $count; + } + + // -------------------------------------------------------------------- + + /** + * Field data + * + * Generates an array of objects containing field meta-data + * + * @access public + * @return array + */ + function field_data() + { + $retval = array(); + $fieldCount = $this->num_fields(); + for ($c = 1; $c <= $fieldCount; $c++) + { + $F = new stdClass(); + $F->name = ocicolumnname($this->stmt_id, $c); + $F->type = ocicolumntype($this->stmt_id, $c); + $F->max_length = ocicolumnsize($this->stmt_id, $c); + + $retval[] = $F; + } + + return $retval; + } + + // -------------------------------------------------------------------- + + /** + * Free the result + * + * @return null + */ + function free_result() + { + if (is_resource($this->result_id)) + { + OCIFreeStatement($this->result_id); + $this->result_id = FALSE; + } + } + + // -------------------------------------------------------------------- + + /** + * Result - associative array + * + * Returns the result set as an array + * + * @access private + * @return array + */ + function _fetch_assoc(&$row) + { + // if pulling from a cursor, use curs_id + if ($this->curs_id) + { + return ocifetchinto($this->curs_id, $row, OCI_ASSOC + OCI_RETURN_NULLS); + } + else + { + return ocifetchinto($this->stmt_id, $row, OCI_ASSOC + OCI_RETURN_NULLS); + } + } + + // -------------------------------------------------------------------- + + /** + * Result - object + * + * Returns the result set as an object + * + * @access private + * @return object + */ + function _fetch_object() + { + // the PHP 4 version of the oracle functions do not + // have a fetch method so we call the array version + // and build an object from that + + $row = array(); + $res = $this->_fetch_assoc($row); + if ($res != FALSE) + { + $obj = new stdClass(); + foreach ($row as $key => $value) + { + $obj->{$key} = $value; + } + + $res = $obj; + } + return $res; + } + + /** + * Query result. "array" version. + * + * @access public + * @return array + */ + function result_array() + { + if (count($this->result_array) > 0) + { + return $this->result_array; + } + + // oracle's fetch functions do not + // return arrays, the information + // is returned in reference parameters + // + $row = NULL; + while ($this->_fetch_assoc($row)) + { + $this->result_array[] = $row; + } + + if (count($this->result_array) == 0) + { + return FALSE; + } + + return $this->result_array; + } + +} + +?>
\ No newline at end of file |