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  
   4  /*
   5  @version   v5.21.0  2021-02-27
   6  @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
   7  @copyright (c) 2014      Damien Regad, Mark Newnham and the ADOdb community
   8    Released under both BSD license and Lesser GPL library license.
   9    Whenever there is any discrepancy between the two licenses,
  10    the BSD license will take precedence.
  11    Set tabs to 8.
  12  
  13  */
  14  
  15  class ADODB_pdo_oci extends ADODB_pdo_base {
  16  
  17  	 var $concat_operator='||';
  18  	 var $sysDate = "TRUNC(SYSDATE)";
  19  	 var $sysTimeStamp = 'SYSDATE';
  20  	 var $NLS_DATE_FORMAT = 'YYYY-MM-DD';  // To include time, use 'RRRR-MM-DD HH24:MI:SS'
  21  	 var $random = "abs(mod(DBMS_RANDOM.RANDOM,10000001)/10000000)";
  22  	 var $metaTablesSQL = "select table_name,table_type from cat where table_type in ('TABLE','VIEW')";
  23  	 var $metaColumnsSQL = "select cname,coltype,width, SCALE, PRECISION, NULLS, DEFAULTVAL from col where tname='%s' order by colno";
  24  
  25   	 var $_initdate = true;
  26  	 var $_hasdual = true;
  27  
  28  	function _init($parentDriver)
  29  	 {
  30  	 	 $parentDriver->_bindInputArray = true;
  31  	 	 $parentDriver->_nestedSQL = true;
  32  	 	 if ($this->_initdate) {
  33  	 	 	 $parentDriver->Execute("ALTER SESSION SET NLS_DATE_FORMAT='".$this->NLS_DATE_FORMAT."'");
  34  	 	 }
  35  	 }
  36  
  37  	function MetaTables($ttype=false,$showSchema=false,$mask=false)
  38  	 {
  39  	 	 if ($mask) {
  40  	 	 	 $save = $this->metaTablesSQL;
  41  	 	 	 $mask = $this->qstr(strtoupper($mask));
  42  	 	 	 $this->metaTablesSQL .= " AND table_name like $mask";
  43  	 	 }
  44  	 	 $ret = ADOConnection::MetaTables($ttype,$showSchema);
  45  
  46  	 	 if ($mask) {
  47  	 	 	 $this->metaTablesSQL = $save;
  48  	 	 }
  49  	 	 return $ret;
  50  	 }
  51  
  52  	function MetaColumns($table,$normalize=true)
  53  	 {
  54  	 global $ADODB_FETCH_MODE;
  55  
  56  	 	 $false = false;
  57  	 	 $save = $ADODB_FETCH_MODE;
  58  	 	 $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
  59  	 	 if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
  60  
  61  	 	 $rs = $this->Execute(sprintf($this->metaColumnsSQL,strtoupper($table)));
  62  
  63  	 	 if (isset($savem)) $this->SetFetchMode($savem);
  64  	 	 $ADODB_FETCH_MODE = $save;
  65  	 	 if (!$rs) {
  66  	 	 	 return $false;
  67  	 	 }
  68  	 	 $retarr = array();
  69  	 	 while (!$rs->EOF) { //print_r($rs->fields);
  70  	 	 	 $fld = new ADOFieldObject();
  71  	    	 	 $fld->name = $rs->fields[0];
  72  	    	 	 $fld->type = $rs->fields[1];
  73  	    	 	 $fld->max_length = $rs->fields[2];
  74  	 	 	 $fld->scale = $rs->fields[3];
  75  	 	 	 if ($rs->fields[1] == 'NUMBER' && $rs->fields[3] == 0) {
  76  	 	 	 	 $fld->type ='INT';
  77  	      	 	 $fld->max_length = $rs->fields[4];
  78  	     	 }
  79  	 	    	 $fld->not_null = (strncmp($rs->fields[5], 'NOT',3) === 0);
  80  	 	 	 $fld->binary = (strpos($fld->type,'BLOB') !== false);
  81  	 	 	 $fld->default_value = $rs->fields[6];
  82  
  83  	 	 	 if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld;
  84  	 	 	 else $retarr[strtoupper($fld->name)] = $fld;
  85  	 	 	 $rs->MoveNext();
  86  	 	 }
  87  	 	 $rs->Close();
  88  	 	 if (empty($retarr))
  89  	 	 	 return  $false;
  90  	 	 else
  91  	 	 	 return $retarr;
  92  	 }
  93  
  94      /**
  95       * @param bool $auto_commit
  96       * @return void
  97       */
  98      function SetAutoCommit($auto_commit)
  99      {
 100          $this->_connectionID->setAttribute(PDO::ATTR_AUTOCOMMIT, $auto_commit);
 101      }
 102  }