3 V4.94 23 Jan 2007 (c) 2000-2007 John Lim. All rights reserved.
4 Released under both BSD license and Lesser GPL library license.
5 Whenever there is any discrepancy between the two licenses,
6 the BSD license will take precedence.
8 Latest version is available at http://adodb.sourceforge.net
10 Portable version of oci8 driver, to make it more similar to other database drivers.
11 The main differences are
13 1. that the OCI_ASSOC names are in lowercase instead of uppercase.
14 2. bind variables are mapped using ? instead of :<bindvar>
16 Should some emulation of RecordCount() be implemented?
20 // security - hide paths
21 if (!defined('ADODB_DIR')) die();
23 include_once(ADODB_DIR
.'/drivers/adodb-oci8.inc.php');
25 class ADODB_oci8po
extends ADODB_oci8
{
26 var $databaseType = 'oci8po';
27 var $dataProvider = 'oci8';
28 var $metaColumnsSQL = "select lower(cname),coltype,width, SCALE, PRECISION, NULLS, DEFAULTVAL from col where tname='%s' order by colno"; //changed by smondino@users.sourceforge. net
29 var $metaTablesSQL = "select lower(table_name),table_type from cat where table_type in ('TABLE','VIEW')";
31 function ADODB_oci8po()
33 $this->_hasOCIFetchStatement
= ADODB_PHPVER
>= 0x4200;
34 # oci8po does not support adodb extension: adodb_movenext()
42 function Prepare($sql,$cursor=false)
44 $sqlarr = explode('?',$sql);
46 for ($i = 1, $max = sizeof($sqlarr); $i < $max; $i++
) {
47 $sql .= ':'.($i-1) . $sqlarr[$i];
49 return ADODB_oci8
::Prepare($sql,$cursor);
52 // emulate handling of parameters ? ?, replacing with :bind0 :bind1
53 function _query($sql,$inputarr)
55 if (is_array($inputarr)) {
58 foreach($inputarr as $v) {
59 $arr['bind'.$i++
] = $v;
62 $sqlarr = explode('?',$sql);
64 foreach($inputarr as $k => $v) {
65 $sql .= ":$k" . $sqlarr[++
$i];
69 return ADODB_oci8
::_query($sql,$inputarr);
73 /*--------------------------------------------------------------------------------------
75 --------------------------------------------------------------------------------------*/
77 class ADORecordset_oci8po
extends ADORecordset_oci8
{
79 var $databaseType = 'oci8po';
81 function ADORecordset_oci8po($queryID,$mode=false)
83 $this->ADORecordset_oci8($queryID,$mode);
86 function Fields($colname)
88 if ($this->fetchMode
& OCI_ASSOC
) return $this->fields
[$colname];
91 $this->bind
= array();
92 for ($i=0; $i < $this->_numOfFields
; $i++
) {
93 $o = $this->FetchField($i);
94 $this->bind
[strtoupper($o->name
)] = $i;
97 return $this->fields
[$this->bind
[strtoupper($colname)]];
100 // lowercase field names...
101 function &_FetchField($fieldOffset = -1)
103 $fld = new ADOFieldObject
;
105 $fld->name
= strtolower(OCIcolumnname($this->_queryID
, $fieldOffset));
106 $fld->type
= OCIcolumntype($this->_queryID
, $fieldOffset);
107 $fld->max_length
= OCIcolumnsize($this->_queryID
, $fieldOffset);
108 if ($fld->type
== 'NUMBER') {
109 //$p = OCIColumnPrecision($this->_queryID, $fieldOffset);
110 $sc = OCIColumnScale($this->_queryID
, $fieldOffset);
111 if ($sc == 0) $fld->type
= 'INT';
118 if (@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) {
119 $this->_currentRow += 1;
123 $this->_currentRow += 1;
129 // 10% speedup to move MoveNext to child class
132 if(@OCIfetchinto
($this->_queryID
,$this->fields
,$this->fetchMode
)) {
133 global $ADODB_ANSI_PADDING_OFF;
134 $this->_currentRow++
;
136 if ($this->fetchMode
& OCI_ASSOC
) $this->_updatefields();
137 if (!empty($ADODB_ANSI_PADDING_OFF)) {
138 foreach($this->fields
as $k => $v) {
139 if (is_string($v)) $this->fields
[$k] = rtrim($v);
146 $this->_currentRow++
;
151 /* Optimize SelectLimit() by using OCIFetch() instead of OCIFetchInto() */
152 function &GetArrayLimit($nrows,$offset=-1)
155 $arr = $this->GetArray($nrows);
158 for ($i=1; $i < $offset; $i++
)
159 if (!@OCIFetch
($this->_queryID
)) {
163 if (!@OCIfetchinto
($this->_queryID
,$this->fields
,$this->fetchMode
)) {
167 if ($this->fetchMode
& OCI_ASSOC
) $this->_updatefields();
170 while (!$this->EOF
&& $nrows != $cnt) {
171 $results[$cnt++
] = $this->fields
;
178 // Create associative array
179 function _updatefields()
181 if (ADODB_ASSOC_CASE
== 2) return; // native
184 $lowercase = (ADODB_ASSOC_CASE
== 0);
186 foreach($this->fields
as $k => $v) {
187 if (is_integer($k)) $arr[$k] = $v;
190 $arr[strtolower($k)] = $v;
192 $arr[strtoupper($k)] = $v;
195 $this->fields
= $arr;
200 $ret = @OCIfetchinto
($this->_queryID
,$this->fields
,$this->fetchMode
);
202 global $ADODB_ANSI_PADDING_OFF;
204 if ($this->fetchMode
& OCI_ASSOC
) $this->_updatefields();
205 if (!empty($ADODB_ANSI_PADDING_OFF)) {
206 foreach($this->fields
as $k => $v) {
207 if (is_string($v)) $this->fields
[$k] = rtrim($v);