Support new security model in the formSubmit function - bug fix
[openemr.git] / library / adodb / drivers / adodb-oci8po.inc.php
blob4202183c390daa793b4964a712781bb649d5cda1
1 <?php
2 /*
3 V5.14 8 Sept 2011 (c) 2000-2011 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()
37 function Param($name)
39 return '?';
42 function Prepare($sql,$cursor=false)
44 $sqlarr = explode('?',$sql);
45 $sql = $sqlarr[0];
46 for ($i = 1, $max = sizeof($sqlarr); $i < $max; $i++) {
47 $sql .= ':'.($i-1) . $sqlarr[$i];
49 return ADODB_oci8::Prepare($sql,$cursor);
52 function Execute($sql,$inputarr=false)
54 return ADOConnection::Execute($sql,$inputarr);
57 // emulate handling of parameters ? ?, replacing with :bind0 :bind1
58 function _query($sql,$inputarr=false)
60 if (is_array($inputarr)) {
61 $i = 0;
62 if (is_array($sql)) {
63 foreach($inputarr as $v) {
64 $arr['bind'.$i++] = $v;
66 } else {
67 $sqlarr = explode('?',$sql);
68 $sql = $sqlarr[0];
69 foreach($inputarr as $k => $v) {
70 $sql .= ":$k" . $sqlarr[++$i];
74 return ADODB_oci8::_query($sql,$inputarr);
78 /*--------------------------------------------------------------------------------------
79 Class Name: Recordset
80 --------------------------------------------------------------------------------------*/
82 class ADORecordset_oci8po extends ADORecordset_oci8 {
84 var $databaseType = 'oci8po';
86 function ADORecordset_oci8po($queryID,$mode=false)
88 $this->ADORecordset_oci8($queryID,$mode);
91 function Fields($colname)
93 if ($this->fetchMode & OCI_ASSOC) return $this->fields[$colname];
95 if (!$this->bind) {
96 $this->bind = array();
97 for ($i=0; $i < $this->_numOfFields; $i++) {
98 $o = $this->FetchField($i);
99 $this->bind[strtoupper($o->name)] = $i;
102 return $this->fields[$this->bind[strtoupper($colname)]];
105 // lowercase field names...
106 function _FetchField($fieldOffset = -1)
108 $fld = new ADOFieldObject;
109 $fieldOffset += 1;
110 $fld->name = OCIcolumnname($this->_queryID, $fieldOffset);
111 if (ADODB_ASSOC_CASE == 0) $fld->name = strtolower($fld->name);
112 $fld->type = OCIcolumntype($this->_queryID, $fieldOffset);
113 $fld->max_length = OCIcolumnsize($this->_queryID, $fieldOffset);
114 if ($fld->type == 'NUMBER') {
115 //$p = OCIColumnPrecision($this->_queryID, $fieldOffset);
116 $sc = OCIColumnScale($this->_queryID, $fieldOffset);
117 if ($sc == 0) $fld->type = 'INT';
119 return $fld;
122 function MoveNext()
124 if (@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) {
125 $this->_currentRow += 1;
126 return true;
128 if (!$this->EOF) {
129 $this->_currentRow += 1;
130 $this->EOF = true;
132 return false;
135 // 10% speedup to move MoveNext to child class
136 function MoveNext()
138 if(@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) {
139 global $ADODB_ANSI_PADDING_OFF;
140 $this->_currentRow++;
142 if ($this->fetchMode & OCI_ASSOC) $this->_updatefields();
143 if (!empty($ADODB_ANSI_PADDING_OFF)) {
144 foreach($this->fields as $k => $v) {
145 if (is_string($v)) $this->fields[$k] = rtrim($v);
148 return true;
150 if (!$this->EOF) {
151 $this->EOF = true;
152 $this->_currentRow++;
154 return false;
157 /* Optimize SelectLimit() by using OCIFetch() instead of OCIFetchInto() */
158 function GetArrayLimit($nrows,$offset=-1)
160 if ($offset <= 0) {
161 $arr = $this->GetArray($nrows);
162 return $arr;
164 for ($i=1; $i < $offset; $i++)
165 if (!@OCIFetch($this->_queryID)) {
166 $arr = array();
167 return $arr;
169 if (!@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) {
170 $arr = array();
171 return $arr;
173 if ($this->fetchMode & OCI_ASSOC) $this->_updatefields();
174 $results = array();
175 $cnt = 0;
176 while (!$this->EOF && $nrows != $cnt) {
177 $results[$cnt++] = $this->fields;
178 $this->MoveNext();
181 return $results;
184 // Create associative array
185 function _updatefields()
187 if (ADODB_ASSOC_CASE == 2) return; // native
189 $arr = array();
190 $lowercase = (ADODB_ASSOC_CASE == 0);
192 foreach($this->fields as $k => $v) {
193 if (is_integer($k)) $arr[$k] = $v;
194 else {
195 if ($lowercase)
196 $arr[strtolower($k)] = $v;
197 else
198 $arr[strtoupper($k)] = $v;
201 $this->fields = $arr;
204 function _fetch()
206 $ret = @OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode);
207 if ($ret) {
208 global $ADODB_ANSI_PADDING_OFF;
210 if ($this->fetchMode & OCI_ASSOC) $this->_updatefields();
211 if (!empty($ADODB_ANSI_PADDING_OFF)) {
212 foreach($this->fields as $k => $v) {
213 if (is_string($v)) $this->fields[$k] = rtrim($v);
217 return $ret;