Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 310 and 311] [Versions 310 and 400] [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403]

   1  <?php
   2  /*
   3  @version   v5.20.16  12-Jan-2020
   4  @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). 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  Set tabs to 4 for best viewing.
  10  
  11    Latest version is available at http://adodb.org/
  12  
  13    Microsoft Visual FoxPro data driver. Requires ODBC. Works only on MS Windows.
  14  */
  15  
  16  // security - hide paths
  17  if (!defined('ADODB_DIR')) die();
  18  include(ADODB_DIR."/drivers/adodb-db2.inc.php");
  19  
  20  
  21  if (!defined('ADODB_DB2OCI')){
  22  define('ADODB_DB2OCI',1);
  23  
  24  
  25  /**
  26   * Callback function for preg_replace in _colonscope()
  27   * @param array $p matched patterns
  28   * return string '?' if parameter replaced, :N if not
  29   */
  30  function _colontrack($p)
  31  {
  32  	 global $_COLONARR, $_COLONSZ;
  33  	 $v = (integer) substr($p[1], 1);
  34  	 if ($v > $_COLONSZ) return $p[1];
  35  	 $_COLONARR[] = $v;
  36  	 return '?';
  37  }
  38  
  39  /**
  40   * smart remapping of :0, :1 bind vars to ? ?
  41   * @param string $sql SQL statement
  42   * @param array  $arr parameters
  43   * @return array
  44   */
  45  function _colonscope($sql,$arr)
  46  {
  47  global $_COLONARR,$_COLONSZ;
  48  
  49  	 $_COLONARR = array();
  50  	 $_COLONSZ = sizeof($arr);
  51  
  52  	 $sql2 = preg_replace_callback('/(:[0-9]+)/', '_colontrack', $sql);
  53  
  54  	 if (empty($_COLONARR)) return array($sql,$arr);
  55  
  56  	 foreach($_COLONARR as $k => $v) {
  57  	 	 $arr2[] = $arr[$v];
  58  	 }
  59  
  60  	 return array($sql2,$arr2);
  61  }
  62  
  63  class ADODB_db2oci extends ADODB_db2 {
  64  	 var $databaseType = "db2oci";
  65  	 var $sysTimeStamp = 'sysdate';
  66  	 var $sysDate = 'trunc(sysdate)';
  67  
  68  	function _Execute($sql, $inputarr = false)
  69  	 {
  70  	 	 if ($inputarr) list($sql,$inputarr) = _colonscope($sql, $inputarr);
  71  	 	 return parent::_Execute($sql, $inputarr);
  72  	 }
  73  };
  74  
  75  
  76  class  ADORecordSet_db2oci extends ADORecordSet_odbc {
  77  
  78  	 var $databaseType = "db2oci";
  79  
  80  	function __construct($id,$mode=false)
  81  	 {
  82  	 	 return parent::__construct($id,$mode);
  83  	 }
  84  }
  85  
  86  } //define