[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 @version v5.20.3 01-Jan-2016 4 @copyright (c) 2000-2013 John Lim. All rights reserved. 5 @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community 6 Released under both BSD license and Lesser GPL library license. 7 Whenever there is any discrepancy between the two licenses, 8 the BSD license will take precedence. 9 10 Latest version is available at http://adodb.sourceforge.net 11 12 Portable version of oci8 driver, to make it more similar to other database drivers. 13 The main differences are 14 15 1. that the OCI_ASSOC names are in lowercase instead of uppercase. 16 2. bind variables are mapped using ? instead of :<bindvar> 17 18 Should some emulation of RecordCount() be implemented? 19 20 */ 21 22 // security - hide paths 23 if (!defined('ADODB_DIR')) die(); 24 25 include_once(ADODB_DIR.'/drivers/adodb-oci8.inc.php'); 26 27 class ADODB_oci8po extends ADODB_oci8 { 28 var $databaseType = 'oci8po'; 29 var $dataProvider = 'oci8'; 30 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 31 var $metaTablesSQL = "select lower(table_name),table_type from cat where table_type in ('TABLE','VIEW')"; 32 33 function __construct() 34 { 35 $this->_hasOCIFetchStatement = ADODB_PHPVER >= 0x4200; 36 # oci8po does not support adodb extension: adodb_movenext() 37 } 38 39 function Param($name,$type='C') 40 { 41 return '?'; 42 } 43 44 function Prepare($sql,$cursor=false) 45 { 46 $sqlarr = explode('?',$sql); 47 $sql = $sqlarr[0]; 48 for ($i = 1, $max = sizeof($sqlarr); $i < $max; $i++) { 49 $sql .= ':'.($i-1) . $sqlarr[$i]; 50 } 51 return ADODB_oci8::Prepare($sql,$cursor); 52 } 53 54 function Execute($sql,$inputarr=false) 55 { 56 return ADOConnection::Execute($sql,$inputarr); 57 } 58 59 // emulate handling of parameters ? ?, replacing with :bind0 :bind1 60 function _query($sql,$inputarr=false) 61 { 62 if (is_array($inputarr)) { 63 $i = 0; 64 if (is_array($sql)) { 65 foreach($inputarr as $v) { 66 $arr['bind'.$i++] = $v; 67 } 68 } else { 69 // Need to identify if the ? is inside a quoted string, and if 70 // so not use it as a bind variable 71 preg_match_all('/".*\??"|\'.*\?.*?\'/', $sql, $matches); 72 foreach($matches[0] as $qmMatch){ 73 $qmReplace = str_replace('?', '-QUESTIONMARK-', $qmMatch); 74 $sql = str_replace($qmMatch, $qmReplace, $sql); 75 } 76 77 $sqlarr = explode('?',$sql); 78 $sql = $sqlarr[0]; 79 80 foreach($inputarr as $k => $v) { 81 $sql .= ":$k" . $sqlarr[++$i]; 82 } 83 84 $sql = str_replace('-QUESTIONMARK-', '?', $sql); 85 } 86 } 87 return ADODB_oci8::_query($sql,$inputarr); 88 } 89 } 90 91 /*-------------------------------------------------------------------------------------- 92 Class Name: Recordset 93 --------------------------------------------------------------------------------------*/ 94 95 class ADORecordset_oci8po extends ADORecordset_oci8 { 96 97 var $databaseType = 'oci8po'; 98 99 function __construct($queryID,$mode=false) 100 { 101 parent::__construct($queryID,$mode); 102 } 103 104 function Fields($colname) 105 { 106 if ($this->fetchMode & OCI_ASSOC) return $this->fields[$colname]; 107 108 if (!$this->bind) { 109 $this->bind = array(); 110 for ($i=0; $i < $this->_numOfFields; $i++) { 111 $o = $this->FetchField($i); 112 $this->bind[strtoupper($o->name)] = $i; 113 } 114 } 115 return $this->fields[$this->bind[strtoupper($colname)]]; 116 } 117 118 // lowercase field names... 119 function _FetchField($fieldOffset = -1) 120 { 121 $fld = new ADOFieldObject; 122 $fieldOffset += 1; 123 $fld->name = OCIcolumnname($this->_queryID, $fieldOffset); 124 if (ADODB_ASSOC_CASE == ADODB_ASSOC_CASE_LOWER) { 125 $fld->name = strtolower($fld->name); 126 } 127 $fld->type = OCIcolumntype($this->_queryID, $fieldOffset); 128 $fld->max_length = OCIcolumnsize($this->_queryID, $fieldOffset); 129 if ($fld->type == 'NUMBER') { 130 $sc = OCIColumnScale($this->_queryID, $fieldOffset); 131 if ($sc == 0) { 132 $fld->type = 'INT'; 133 } 134 } 135 return $fld; 136 } 137 138 // 10% speedup to move MoveNext to child class 139 function MoveNext() 140 { 141 $ret = @oci_fetch_array($this->_queryID,$this->fetchMode); 142 if($ret !== false) { 143 global $ADODB_ANSI_PADDING_OFF; 144 $this->fields = $ret; 145 $this->_currentRow++; 146 $this->_updatefields(); 147 148 if (!empty($ADODB_ANSI_PADDING_OFF)) { 149 foreach($this->fields as $k => $v) { 150 if (is_string($v)) $this->fields[$k] = rtrim($v); 151 } 152 } 153 return true; 154 } 155 if (!$this->EOF) { 156 $this->EOF = true; 157 $this->_currentRow++; 158 } 159 return false; 160 } 161 162 /* Optimize SelectLimit() by using OCIFetch() instead of OCIFetchInto() */ 163 function GetArrayLimit($nrows,$offset=-1) 164 { 165 if ($offset <= 0) { 166 $arr = $this->GetArray($nrows); 167 return $arr; 168 } 169 for ($i=1; $i < $offset; $i++) 170 if (!@OCIFetch($this->_queryID)) { 171 $arr = array(); 172 return $arr; 173 } 174 $ret = @oci_fetch_array($this->_queryID,$this->fetchMode); 175 if ($ret === false) { 176 $arr = array(); 177 return $arr; 178 } 179 $this->fields = $ret; 180 $this->_updatefields(); 181 $results = array(); 182 $cnt = 0; 183 while (!$this->EOF && $nrows != $cnt) { 184 $results[$cnt++] = $this->fields; 185 $this->MoveNext(); 186 } 187 188 return $results; 189 } 190 191 function _fetch() 192 { 193 global $ADODB_ANSI_PADDING_OFF; 194 195 $ret = @oci_fetch_array($this->_queryID,$this->fetchMode); 196 if ($ret) { 197 $this->fields = $ret; 198 $this->_updatefields(); 199 200 if (!empty($ADODB_ANSI_PADDING_OFF)) { 201 foreach($this->fields as $k => $v) { 202 if (is_string($v)) $this->fields[$k] = rtrim($v); 203 } 204 } 205 } 206 return $ret !== false; 207 } 208 209 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |