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]

   1  <?php
   2  
   3  /*
   4  @version   v5.20.16  12-Jan-2020
   5  @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
   6  @copyright (c) 2014      Damien Regad, Mark Newnham and the ADOdb community
   7    Released under both BSD license and Lesser GPL library license.
   8    Whenever there is any discrepancy between the two licenses,
   9    the BSD license will take precedence.
  10    Set tabs to 8.
  11  
  12    MySQL code that supports transactions. For MySQL 3.23 or later.
  13    Code from James Poon <jpoon88@yahoo.com>
  14    
  15    This driver extends the deprecated mysql driver, and was originally designed to be a 
  16    portable driver in the same manner as oci8po and mssqlpo. Its functionality
  17    is exactly duplicated in the mysqlt driver, which is itself deprecated.
  18    This driver will be removed in ADOdb version 6.0.0.
  19  
  20    Requires mysql client. Works on Windows and Unix.
  21  */
  22  
  23  // security - hide paths
  24  if (!defined('ADODB_DIR')) die();
  25  
  26  include_once(ADODB_DIR."/drivers/adodb-mysql.inc.php");
  27  
  28  
  29  class ADODB_mysqlt extends ADODB_mysql {
  30  	 var $databaseType = 'mysqlt';
  31  	 var $ansiOuter = true; // for Version 3.23.17 or later
  32  	 var $hasTransactions = true;
  33  	 var $autoRollback = true; // apparently mysql does not autorollback properly
  34  
  35  	function __construct()
  36  	 {
  37  	 global $ADODB_EXTENSION; if ($ADODB_EXTENSION) $this->rsPrefix .= 'ext_';
  38  	 }
  39  
  40  	function BeginTrans()
  41  	 {
  42  	 	 if ($this->transOff) return true;
  43  	 	 $this->transCnt += 1;
  44  	 	 $this->Execute('SET AUTOCOMMIT=0');
  45  	 	 $this->Execute('BEGIN');
  46  	 	 return true;
  47  	 }
  48  
  49  	function CommitTrans($ok=true)
  50  	 {
  51  	 	 if ($this->transOff) return true;
  52  	 	 if (!$ok) return $this->RollbackTrans();
  53  
  54  	 	 if ($this->transCnt) $this->transCnt -= 1;
  55  	 	 $this->Execute('COMMIT');
  56  	 	 $this->Execute('SET AUTOCOMMIT=1');
  57  	 	 return true;
  58  	 }
  59  
  60  	function RollbackTrans()
  61  	 {
  62  	 	 if ($this->transOff) return true;
  63  	 	 if ($this->transCnt) $this->transCnt -= 1;
  64  	 	 $this->Execute('ROLLBACK');
  65  	 	 $this->Execute('SET AUTOCOMMIT=1');
  66  	 	 return true;
  67  	 }
  68  
  69  	function RowLock($tables,$where='',$col='1 as adodbignore')
  70  	 {
  71  	 	 if ($this->transCnt==0) $this->BeginTrans();
  72  	 	 if ($where) $where = ' where '.$where;
  73  	 	 $rs = $this->Execute("select $col from $tables $where for update");
  74  	 	 return !empty($rs);
  75  	 }
  76  
  77  }
  78  
  79  class ADORecordSet_mysqlt extends ADORecordSet_mysql{
  80  	 var $databaseType = "mysqlt";
  81  
  82  	function __construct($queryID,$mode=false)
  83  	 {
  84  	 	 if ($mode === false) {
  85  	 	 	 global $ADODB_FETCH_MODE;
  86  	 	 	 $mode = $ADODB_FETCH_MODE;
  87  	 	 }
  88  
  89  	 	 switch ($mode)
  90  	 	 {
  91  	 	 case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break;
  92  	 	 case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break;
  93  
  94  	 	 case ADODB_FETCH_DEFAULT:
  95  	 	 case ADODB_FETCH_BOTH:
  96  	 	 default: $this->fetchMode = MYSQL_BOTH; break;
  97  	 	 }
  98  
  99  	 	 $this->adodbFetchMode = $mode;
 100  	 	 parent::__construct($queryID);
 101  	 }
 102  
 103  	function MoveNext()
 104  	 {
 105  	 	 if (@$this->fields = mysql_fetch_array($this->_queryID,$this->fetchMode)) {
 106  	 	 	 $this->_currentRow += 1;
 107  	 	 	 return true;
 108  	 	 }
 109  	 	 if (!$this->EOF) {
 110  	 	 	 $this->_currentRow += 1;
 111  	 	 	 $this->EOF = true;
 112  	 	 }
 113  	 	 return false;
 114  	 }
 115  }
 116  
 117  class ADORecordSet_ext_mysqlt extends ADORecordSet_mysqlt {
 118  
 119  	function __construct($queryID,$mode=false)
 120  	 {
 121  	 	 parent::__construct($queryID,$mode);
 122  	 }
 123  
 124  	function MoveNext()
 125  	 {
 126  	 	 return adodb_movenext($this);
 127  	 }
 128  }