From 7b613c7000a496fe0e4f9152ee8937d06eba2301 Mon Sep 17 00:00:00 2001 From: admin Date: Sun, 24 Sep 2006 18:05:17 +0000 Subject: Adding database folder --- system/database/drivers/oci8/oci8_result.php | 207 +++++++++++++++++++++++++++ 1 file changed, 207 insertions(+) create mode 100644 system/database/drivers/oci8/oci8_result.php (limited to 'system/database/drivers/oci8/oci8_result.php') 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 @@ +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 -- cgit v1.2.3-24-g4f1b