Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402]
1 <?php 2 /** 3 * IBM DB2 / Oracle compatibility driver. 4 * 5 * This driver re-maps ibm :0 bind variables to oracle compatible ? variables. 6 * 7 * @deprecated 8 * 9 * This file is part of ADOdb, a Database Abstraction Layer library for PHP. 10 * 11 * @package ADOdb 12 * @link https://adodb.org Project's web site and documentation 13 * @link https://github.com/ADOdb/ADOdb Source code and issue tracker 14 * 15 * The ADOdb Library is dual-licensed, released under both the BSD 3-Clause 16 * and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option, 17 * any later version. This means you can use it in proprietary products. 18 * See the LICENSE.md file distributed with this source code for details. 19 * @license BSD-3-Clause 20 * @license LGPL-2.1-or-later 21 * 22 * @copyright 2000-2013 John Lim 23 * @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community 24 */ 25 26 // security - hide paths 27 if (!defined('ADODB_DIR')) die(); 28 include_once(ADODB_DIR."/drivers/adodb-db2.inc.php"); 29 30 31 if (!defined('ADODB_DB2OCI')){ 32 define('ADODB_DB2OCI',1); 33 34 /** 35 * Smart remapping of :0, :1 bind vars to ? ? 36 * Handles colons in comments -- and / * * / and in quoted strings. 37 * @param string $sql SQL statement 38 * @param array $arr parameters 39 * @return array 40 */ 41 function _colonparser($sql,$arr) 42 { 43 $lensql = strlen($sql); 44 $arrsize = sizeof($arr); 45 $state = 'NORM'; 46 $at = 1; 47 $ch = $sql[0]; 48 $ch2 = @$sql[1]; 49 $sql2 = ''; 50 $arr2 = array(); 51 $nprev = 0; 52 53 54 while (strlen($ch)) { 55 56 switch($ch) { 57 case '/': 58 if ($state == 'NORM' && $ch2 == '*') { 59 $state = 'COMMENT'; 60 61 $at += 1; 62 $ch = $ch2; 63 $ch2 = $at < $lensql ? $sql[$at] : ''; 64 } 65 break; 66 67 case '*': 68 if ($state == 'COMMENT' && $ch2 == '/') { 69 $state = 'NORM'; 70 71 $at += 1; 72 $ch = $ch2; 73 $ch2 = $at < $lensql ? $sql[$at] : ''; 74 } 75 break; 76 77 case "\n": 78 case "\r": 79 if ($state == 'COMMENT2') $state = 'NORM'; 80 break; 81 82 case "'": 83 do { 84 $at += 1; 85 $ch = $ch2; 86 $ch2 = $at < $lensql ? $sql[$at] : ''; 87 } while ($ch !== "'"); 88 break; 89 90 case ':': 91 if ($state == 'COMMENT' || $state == 'COMMENT2') break; 92 93 //echo "$at=$ch $ch2, "; 94 if ('0' <= $ch2 && $ch2 <= '9') { 95 $n = ''; 96 $nat = $at; 97 do { 98 $at += 1; 99 $ch = $ch2; 100 $n .= $ch; 101 $ch2 = $at < $lensql ? $sql[$at] : ''; 102 } while ('0' <= $ch && $ch <= '9'); 103 #echo "$n $arrsize ] "; 104 $n = (integer) $n; 105 if ($n < $arrsize) { 106 $sql2 .= substr($sql,$nprev,$nat-$nprev-1).'?'; 107 $nprev = $at-1; 108 $arr2[] = $arr[$n]; 109 } 110 } 111 break; 112 113 case '-': 114 if ($state == 'NORM') { 115 if ($ch2 == '-') $state = 'COMMENT2'; 116 $at += 1; 117 $ch = $ch2; 118 $ch2 = $at < $lensql ? $sql[$at] : ''; 119 } 120 break; 121 } 122 123 $at += 1; 124 $ch = $ch2; 125 $ch2 = $at < $lensql ? $sql[$at] : ''; 126 } 127 128 if ($nprev == 0) { 129 $sql2 = $sql; 130 } else { 131 $sql2 .= substr($sql,$nprev); 132 } 133 134 return array($sql2,$arr2); 135 } 136 137 class ADODB_db2oci extends ADODB_db2 { 138 var $databaseType = "db2oci"; 139 var $sysTimeStamp = 'sysdate'; 140 var $sysDate = 'trunc(sysdate)'; 141 var $_bindInputArray = true; 142 143 function Param($name,$type='C') 144 { 145 return ':'.$name; 146 } 147 148 149 function MetaTables($ttype = false, $schema = false, $mask = false) 150 { 151 global $ADODB_FETCH_MODE; 152 153 $savem = $ADODB_FETCH_MODE; 154 $ADODB_FETCH_MODE = ADODB_FETCH_NUM; 155 $qid = db2_tables($this->_connectionID); 156 157 $rs = new ADORecordSet_db2($qid); 158 159 $ADODB_FETCH_MODE = $savem; 160 if (!$rs) { 161 $false = false; 162 return $false; 163 } 164 165 $arr = $rs->GetArray(); 166 $rs->Close(); 167 $arr2 = array(); 168 // adodb_pr($arr); 169 if ($ttype) { 170 $isview = strncmp($ttype,'V',1) === 0; 171 } 172 for ($i=0; $i < sizeof($arr); $i++) { 173 if (!$arr[$i][2]) continue; 174 $type = $arr[$i][3]; 175 $schemaval = ($schema) ? $arr[$i][1].'.' : ''; 176 $name = $schemaval.$arr[$i][2]; 177 $owner = $arr[$i][1]; 178 if (substr($name,0,8) == 'EXPLAIN_') continue; 179 if ($ttype) { 180 if ($isview) { 181 if (strncmp($type,'V',1) === 0) $arr2[] = $name; 182 } else if (strncmp($type,'T',1) === 0 && strncmp($owner,'SYS',3) !== 0) $arr2[] = $name; 183 } else if (strncmp($type,'T',1) === 0 && strncmp($owner,'SYS',3) !== 0) $arr2[] = $name; 184 } 185 return $arr2; 186 } 187 188 function _Execute($sql, $inputarr=false ) 189 { 190 if ($inputarr) list($sql,$inputarr) = _colonparser($sql, $inputarr); 191 return parent::_Execute($sql, $inputarr); 192 } 193 }; 194 195 196 class ADORecordSet_db2oci extends ADORecordSet_db2 { 197 198 var $databaseType = "db2oci"; 199 200 } 201 202 } //define
title
Description
Body
title
Description
Body
title
Description
Body
title
Body