Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

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

   1  <?php
   2  /*
   3  @version   v5.21.0  2021-02-27
   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 https://adodb.org/
  12  
  13    Oracle support via ODBC. Requires ODBC. Works on Windows.
  14  */
  15  // security - hide paths
  16  if (!defined('ADODB_DIR')) die();
  17  
  18  if (!defined('_ADODB_ODBC_LAYER')) {
  19  	 include_once(ADODB_DIR."/drivers/adodb-odbc.inc.php");
  20  }
  21  
  22  
  23  class  ADODB_odbc_oracle extends ADODB_odbc {
  24  	 var $databaseType = 'odbc_oracle';
  25   	 var $replaceQuote = "''"; // string to use to replace quotes
  26  	 var $concat_operator='||';
  27  	 var $fmtDate = "'Y-m-d 00:00:00'";
  28  	 var $fmtTimeStamp = "'Y-m-d h:i:sA'";
  29  	 var $metaTablesSQL = 'select table_name from cat';
  30  	 var $metaColumnsSQL = "select cname,coltype,width from col where tname='%s' order by colno";
  31  	 var $sysDate = "TRUNC(SYSDATE)";
  32  	 var $sysTimeStamp = 'SYSDATE';
  33  
  34  	 //var $_bindInputArray = false;
  35  
  36  	function MetaTables($ttype = false, $showSchema = false, $mask = false)
  37  	 {
  38  	 	 $false = false;
  39  	 	 $rs = $this->Execute($this->metaTablesSQL);
  40  	 	 if ($rs === false) return $false;
  41  	 	 $arr = $rs->GetArray();
  42  	 	 $arr2 = array();
  43  	 	 for ($i=0; $i < sizeof($arr); $i++) {
  44  	 	 	 $arr2[] = $arr[$i][0];
  45  	 	 }
  46  	 	 $rs->Close();
  47  	 	 return $arr2;
  48  	 }
  49  
  50  	function MetaColumns($table, $normalize=true)
  51  	 {
  52  	 global $ADODB_FETCH_MODE;
  53  
  54  	 	 $rs = $this->Execute(sprintf($this->metaColumnsSQL,strtoupper($table)));
  55  	 	 if ($rs === false) {
  56  	 	 	 $false = false;
  57  	 	 	 return $false;
  58  	 	 }
  59  	 	 $retarr = array();
  60  	 	 while (!$rs->EOF) { //print_r($rs->fields);
  61  	 	 	 $fld = new ADOFieldObject();
  62  	 	 	 $fld->name = $rs->fields[0];
  63  	 	 	 $fld->type = $rs->fields[1];
  64  	 	 	 $fld->max_length = $rs->fields[2];
  65  
  66  
  67  	 	 	 if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld;
  68  	 	 	 else $retarr[strtoupper($fld->name)] = $fld;
  69  
  70  	 	 	 $rs->MoveNext();
  71  	 	 }
  72  	 	 $rs->Close();
  73  	 	 return $retarr;
  74  	 }
  75  
  76  	 // returns true or false
  77  	function _connect($argDSN, $argUsername, $argPassword, $argDatabasename)
  78  	 {
  79  	 	 $last_php_error = $this->resetLastError();
  80  	 	 $this->_connectionID = odbc_connect($argDSN,$argUsername,$argPassword,SQL_CUR_USE_ODBC );
  81  	 	 $this->_errorMsg = $this->getChangedErrorMsg($last_php_error);
  82  
  83  	 	 $this->Execute("ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'");
  84  	 	 //if ($this->_connectionID) odbc_autocommit($this->_connectionID,true);
  85  	 	 return $this->_connectionID != false;
  86  	 }
  87  	 // returns true or false
  88  	function _pconnect($argDSN, $argUsername, $argPassword, $argDatabasename)
  89  	 {
  90  	 	 $last_php_error = $this->resetLastError();
  91  	 	 $this->_connectionID = odbc_pconnect($argDSN,$argUsername,$argPassword,SQL_CUR_USE_ODBC );
  92  	 	 $this->_errorMsg = $this->getChangedErrorMsg($last_php_error);
  93  
  94  	 	 $this->Execute("ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'");
  95  	 	 //if ($this->_connectionID) odbc_autocommit($this->_connectionID,true);
  96  	 	 return $this->_connectionID != false;
  97  	 }
  98  }
  99  
 100  class  ADORecordSet_odbc_oracle extends ADORecordSet_odbc {
 101  
 102  	 var $databaseType = 'odbc_oracle';
 103  
 104  }