C:/lib/adodb/drivers/adodb-oci8po.inc.php Quellcode

adodb-oci8po.inc.php
gehe zur Dokumentation dieser Datei
1 <?php
2 /*
3 V5.19dev ??-???-2014 (c) 2000-2014 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.
7 
8  Latest version is available at http://adodb.sourceforge.net
9 
10  Portable version of oci8 driver, to make it more similar to other database drivers.
11  The main differences are
12 
13  1. that the OCI_ASSOC names are in lowercase instead of uppercase.
14  2. bind variables are mapped using ? instead of :<bindvar>
15 
16  Should some emulation of RecordCount() be implemented?
17 
18 */
19 
20 // security - hide paths
21 if (!defined('ADODB_DIR')) die();
22 
23 include_once(ADODB_DIR.'/drivers/adodb-oci8.inc.php');
24 
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')";
30 
31  function ADODB_oci8po()
32  {
33  $this->_hasOCIFetchStatement = ADODB_PHPVER >= 0x4200;
34  # oci8po does not support adodb extension: adodb_movenext()
35  }
36 
37  function Param($name,$type='C')
38  {
39  return '?';
40  }
41 
42  function Prepare($sql,$cursor=false)
43  {
44  $sqlarr = explode('?',$sql);
45  $sql = $sqlarr[0];
46  for ($i = 1, $max = sizeof($sqlarr); $i < $max; $i++) {
47  $sql .= ':'.($i-1) . $sqlarr[$i];
48  }
49  return ADODB_oci8::Prepare($sql,$cursor);
50  }
51 
52  function Execute($sql,$inputarr=false)
53  {
54  return ADOConnection::Execute($sql,$inputarr);
55  }
56 
57  // emulate handling of parameters ? ?, replacing with :bind0 :bind1
58  function _query($sql,$inputarr=false)
59  {
60  if (is_array($inputarr)) {
61  $i = 0;
62  if (is_array($sql)) {
63  foreach($inputarr as $v) {
64  $arr['bind'.$i++] = $v;
65  }
66  } else {
67  $sqlarr = explode('?',$sql);
68  $sql = $sqlarr[0];
69  foreach($inputarr as $k => $v) {
70  $sql .= ":$k" . $sqlarr[++$i];
71  }
72  }
73  }
74  return ADODB_oci8::_query($sql,$inputarr);
75  }
76 }
77 
78 /*--------------------------------------------------------------------------------------
79  Class Name: Recordset
80 --------------------------------------------------------------------------------------*/
81 
83 
84  var $databaseType = 'oci8po';
85 
86  function ADORecordset_oci8po($queryID,$mode=false)
87  {
88  $this->ADORecordset_oci8($queryID,$mode);
89  }
90 
91  function Fields($colname)
92  {
93  if ($this->fetchMode & OCI_ASSOC) return $this->fields[$colname];
94 
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;
100  }
101  }
102  return $this->fields[$this->bind[strtoupper($colname)]];
103  }
104 
105  // lowercase field names...
106  function _FetchField($fieldOffset = -1)
107  {
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';
118  }
119  return $fld;
120  }
121  /*
122  function MoveNext()
123  {
124  if (@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) {
125  $this->_currentRow += 1;
126  return true;
127  }
128  if (!$this->EOF) {
129  $this->_currentRow += 1;
130  $this->EOF = true;
131  }
132  return false;
133  }*/
134 
135  // 10% speedup to move MoveNext to child class
136  function MoveNext()
137  {
138  if(@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) {
139  global $ADODB_ANSI_PADDING_OFF;
140  $this->_currentRow++;
141 
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);
146  }
147  }
148  return true;
149  }
150  if (!$this->EOF) {
151  $this->EOF = true;
152  $this->_currentRow++;
153  }
154  return false;
155  }
156 
157  /* Optimize SelectLimit() by using OCIFetch() instead of OCIFetchInto() */
158  function GetArrayLimit($nrows,$offset=-1)
159  {
160  if ($offset <= 0) {
161  $arr = $this->GetArray($nrows);
162  return $arr;
163  }
164  for ($i=1; $i < $offset; $i++)
165  if (!@OCIFetch($this->_queryID)) {
166  $arr = array();
167  return $arr;
168  }
169  if (!@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) {
170  $arr = array();
171  return $arr;
172  }
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();
179  }
180 
181  return $results;
182  }
183 
184  // Create associative array
185  function _updatefields()
186  {
187  if (ADODB_ASSOC_CASE == 2) return; // native
188 
189  $arr = array();
190  $lowercase = (ADODB_ASSOC_CASE == 0);
191 
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;
199  }
200  }
201  $this->fields = $arr;
202  }
203 
204  function _fetch()
205  {
206  $ret = @OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode);
207  if ($ret) {
208  global $ADODB_ANSI_PADDING_OFF;
209 
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);
214  }
215  }
216  }
217  return $ret;
218  }
219 
220 }
221 
222 
223 ?>




Korrekturen, Hinweise und Ergänzungen

Bitte scheuen Sie sich nicht und melden Sie, was auf dieser Seite sachlich falsch oder irreführend ist, was ergänzt werden sollte, was fehlt usw. Dazu bitte oben aus dem Menü Seite den Eintrag Support Forum wählen. Es ist eine kostenlose Anmeldung erforderlich, um Anmerkungen zu posten. Unpassende Postings, Spam usw. werden kommentarlos entfernt.