| 1 | efrain | 1 | <?php
 | 
        
           |  |  | 2 | /**
 | 
        
           |  |  | 3 |  * IBM DB2 / Oracle compatibility driver.
 | 
        
           |  |  | 4 |  *
 | 
        
           |  |  | 5 |  * This driver provides undocumented bind variable mapping from ibm to oracle.
 | 
        
           |  |  | 6 |  * The functionality appears to overlap the db2_oci driver.
 | 
        
           |  |  | 7 |  *
 | 
        
           |  |  | 8 |  * @deprecated
 | 
        
           |  |  | 9 |  *
 | 
        
           |  |  | 10 |  * This file is part of ADOdb, a Database Abstraction Layer library for PHP.
 | 
        
           |  |  | 11 |  *
 | 
        
           |  |  | 12 |  * @package ADOdb
 | 
        
           |  |  | 13 |  * @link https://adodb.org Project's web site and documentation
 | 
        
           |  |  | 14 |  * @link https://github.com/ADOdb/ADOdb Source code and issue tracker
 | 
        
           |  |  | 15 |  *
 | 
        
           |  |  | 16 |  * The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
 | 
        
           |  |  | 17 |  * and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
 | 
        
           |  |  | 18 |  * any later version. This means you can use it in proprietary products.
 | 
        
           |  |  | 19 |  * See the LICENSE.md file distributed with this source code for details.
 | 
        
           |  |  | 20 |  * @license BSD-3-Clause
 | 
        
           |  |  | 21 |  * @license LGPL-2.1-or-later
 | 
        
           |  |  | 22 |  *
 | 
        
           |  |  | 23 |  * @copyright 2000-2013 John Lim
 | 
        
           |  |  | 24 |  * @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
 | 
        
           |  |  | 25 |  */
 | 
        
           |  |  | 26 |   | 
        
           |  |  | 27 | // security - hide paths
 | 
        
           |  |  | 28 | if (!defined('ADODB_DIR')) die();
 | 
        
           |  |  | 29 | include_once(ADODB_DIR."/drivers/adodb-db2.inc.php");
 | 
        
           |  |  | 30 |   | 
        
           |  |  | 31 |   | 
        
           |  |  | 32 | if (!defined('ADODB_DB2OCI')){
 | 
        
           |  |  | 33 | define('ADODB_DB2OCI',1);
 | 
        
           |  |  | 34 |   | 
        
           |  |  | 35 |   | 
        
           |  |  | 36 | /**
 | 
        
           |  |  | 37 |  * Callback function for preg_replace in _colonscope()
 | 
        
           |  |  | 38 |  * @param array $p matched patterns
 | 
        
           |  |  | 39 |  * return string '?' if parameter replaced, :N if not
 | 
        
           |  |  | 40 |  */
 | 
        
           |  |  | 41 | function _colontrack($p)
 | 
        
           |  |  | 42 | {
 | 
        
           |  |  | 43 | 	global $_COLONARR, $_COLONSZ;
 | 
        
           |  |  | 44 | 	$v = (integer) substr($p[1], 1);
 | 
        
           |  |  | 45 | 	if ($v > $_COLONSZ) return $p[1];
 | 
        
           |  |  | 46 | 	$_COLONARR[] = $v;
 | 
        
           |  |  | 47 | 	return '?';
 | 
        
           |  |  | 48 | }
 | 
        
           |  |  | 49 |   | 
        
           |  |  | 50 | /**
 | 
        
           |  |  | 51 |  * smart remapping of :0, :1 bind vars to ? ?
 | 
        
           |  |  | 52 |  * @param string $sql SQL statement
 | 
        
           |  |  | 53 |  * @param array  $arr parameters
 | 
        
           |  |  | 54 |  * @return array
 | 
        
           |  |  | 55 |  */
 | 
        
           |  |  | 56 | function _colonscope($sql,$arr)
 | 
        
           |  |  | 57 | {
 | 
        
           |  |  | 58 | global $_COLONARR,$_COLONSZ;
 | 
        
           |  |  | 59 |   | 
        
           |  |  | 60 | 	$_COLONARR = array();
 | 
        
           |  |  | 61 | 	$_COLONSZ = sizeof($arr);
 | 
        
           |  |  | 62 |   | 
        
           |  |  | 63 | 	$sql2 = preg_replace_callback('/(:[0-9]+)/', '_colontrack', $sql);
 | 
        
           |  |  | 64 |   | 
        
           |  |  | 65 | 	if (empty($_COLONARR)) return array($sql,$arr);
 | 
        
           |  |  | 66 |   | 
        
           |  |  | 67 | 	foreach($_COLONARR as $k => $v) {
 | 
        
           |  |  | 68 | 		$arr2[] = $arr[$v];
 | 
        
           |  |  | 69 | 	}
 | 
        
           |  |  | 70 |   | 
        
           |  |  | 71 | 	return array($sql2,$arr2);
 | 
        
           |  |  | 72 | }
 | 
        
           |  |  | 73 |   | 
        
           |  |  | 74 | class ADODB_db2oci extends ADODB_db2 {
 | 
        
           |  |  | 75 | 	var $databaseType = "db2oci";
 | 
        
           |  |  | 76 | 	var $sysTimeStamp = 'sysdate';
 | 
        
           |  |  | 77 | 	var $sysDate = 'trunc(sysdate)';
 | 
        
           |  |  | 78 |   | 
        
           |  |  | 79 | 	function _Execute($sql, $inputarr = false)
 | 
        
           |  |  | 80 | 	{
 | 
        
           |  |  | 81 | 		if ($inputarr) list($sql,$inputarr) = _colonscope($sql, $inputarr);
 | 
        
           |  |  | 82 | 		return parent::_Execute($sql, $inputarr);
 | 
        
           |  |  | 83 | 	}
 | 
        
           |  |  | 84 | };
 | 
        
           |  |  | 85 |   | 
        
           |  |  | 86 |   | 
        
           |  |  | 87 | class  ADORecordSet_db2oci extends ADORecordSet_odbc {
 | 
        
           |  |  | 88 |   | 
        
           |  |  | 89 | 	var $databaseType = "db2oci";
 | 
        
           |  |  | 90 |   | 
        
           |  |  | 91 | }
 | 
        
           |  |  | 92 |   | 
        
           |  |  | 93 | } //define
 |