summaryrefslogtreecommitdiffstats
path: root/system/database/drivers/oci8/oci8_result.php
diff options
context:
space:
mode:
authorPhil Sturgeon <email@philsturgeon.co.uk>2011-10-22 13:25:41 +0200
committerPhil Sturgeon <email@philsturgeon.co.uk>2011-10-22 13:25:41 +0200
commit8e1ed05d7edad820629df7a21f328d067ca6fe5d (patch)
treedd3caf49a1ad2ca762365b6f275bc2de81049390 /system/database/drivers/oci8/oci8_result.php
parent61df9060d468ce28c40ee4a57d108763f80ec583 (diff)
parentbc95e47181dd8341c10c0437f27609746211ebcd (diff)
Merge pull request #553 from narfbg/ci-oci8-driver-php5
Cleanup and switch oci8_driver and oci8_result to PHP5 functions.
Diffstat (limited to 'system/database/drivers/oci8/oci8_result.php')
-rw-r--r--system/database/drivers/oci8/oci8_result.php87
1 files changed, 27 insertions, 60 deletions
diff --git a/system/database/drivers/oci8/oci8_result.php b/system/database/drivers/oci8/oci8_result.php
index 7d49c620e..3ec71a9d6 100644
--- a/system/database/drivers/oci8/oci8_result.php
+++ b/system/database/drivers/oci8/oci8_result.php
@@ -52,16 +52,16 @@ class CI_DB_oci8_result extends CI_DB_result {
* @access public
* @return integer
*/
- function num_rows()
+ public function num_rows()
{
if ($this->num_rows === 0 && count($this->result_array()) > 0)
{
$this->num_rows = count($this->result_array());
- @ociexecute($this->stmt_id);
+ @oci_execute($this->stmt_id);
if ($this->curs_id)
{
- @ociexecute($this->curs_id);
+ @oci_execute($this->curs_id);
}
}
@@ -76,9 +76,9 @@ class CI_DB_oci8_result extends CI_DB_result {
* @access public
* @return integer
*/
- function num_fields()
+ public function num_fields()
{
- $count = @ocinumcols($this->stmt_id);
+ $count = @oci_num_fields($this->stmt_id);
// if we used a limit we subtract it
if ($this->limit_used)
@@ -99,13 +99,12 @@ class CI_DB_oci8_result extends CI_DB_result {
* @access public
* @return array
*/
- function list_fields()
+ public function list_fields()
{
$field_names = array();
- $fieldCount = $this->num_fields();
- for ($c = 1; $c <= $fieldCount; $c++)
+ for ($c = 1, $fieldCount = $this->num_fields(); $c <= $fieldCount; $c++)
{
- $field_names[] = ocicolumnname($this->stmt_id, $c);
+ $field_names[] = oci_field_name($this->stmt_id, $c);
}
return $field_names;
}
@@ -120,16 +119,15 @@ class CI_DB_oci8_result extends CI_DB_result {
* @access public
* @return array
*/
- function field_data()
+ public function field_data()
{
$retval = array();
- $fieldCount = $this->num_fields();
- for ($c = 1; $c <= $fieldCount; $c++)
+ for ($c = 1, $fieldCount = $this->num_fields(); $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);
+ $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;
}
@@ -144,11 +142,11 @@ class CI_DB_oci8_result extends CI_DB_result {
*
* @return null
*/
- function free_result()
+ public function free_result()
{
if (is_resource($this->result_id))
{
- ocifreestatement($this->result_id);
+ oci_free_statement($this->result_id);
$this->result_id = FALSE;
}
}
@@ -160,14 +158,13 @@ class CI_DB_oci8_result extends CI_DB_result {
*
* Returns the result set as an array
*
- * @access private
+ * @access protected
* @return array
*/
- function _fetch_assoc(&$row)
+ protected function _fetch_assoc()
{
$id = ($this->curs_id) ? $this->curs_id : $this->stmt_id;
-
- return ocifetchinto($id, $row, OCI_ASSOC + OCI_RETURN_NULLS);
+ return oci_fetch_assoc($id);
}
// --------------------------------------------------------------------
@@ -177,41 +174,13 @@ class CI_DB_oci8_result extends CI_DB_result {
*
* Returns the result set as an object
*
- * @access private
+ * @access protected
* @return object
*/
- function _fetch_object()
+ protected function _fetch_object()
{
- $result = array();
-
- // If PHP 5 is being used we can fetch an result object
- if (function_exists('oci_fetch_object'))
- {
- $id = ($this->curs_id) ? $this->curs_id : $this->stmt_id;
-
- return @oci_fetch_object($id);
- }
-
- // If PHP 4 is being used we have to build our own result
- foreach ($this->result_array() as $key => $val)
- {
- $obj = new stdClass();
- if (is_array($val))
- {
- foreach ($val as $k => $v)
- {
- $obj->$k = $v;
- }
- }
- else
- {
- $obj->$key = $val;
- }
-
- $result[] = $obj;
- }
-
- return $result;
+ $id = ($this->curs_id) ? $this->curs_id : $this->stmt_id;
+ return @oci_fetch_object($id);
}
// --------------------------------------------------------------------
@@ -222,17 +191,15 @@ class CI_DB_oci8_result extends CI_DB_result {
* @access public
* @return array
*/
- function result_array()
+ public 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))
+ while ($row = $this->_fetch_assoc())
{
$this->result_array[] = $row;
}
@@ -249,10 +216,10 @@ class CI_DB_oci8_result extends CI_DB_result {
* this internally before fetching results to make sure the
* result set starts at zero
*
- * @access private
+ * @access protected
* @return array
*/
- function _data_seek($n = 0)
+ protected function _data_seek($n = 0)
{
return FALSE; // Not needed
}