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    This driver only supports the original MySQL driver in transactional mode. It
  13    is deprected in PHP version 5.5 and removed in PHP version 7. It is deprecated
  14    as of ADOdb version 5.20.0. Use the mysqli driver instead, which supports both
  15    transactional and non-transactional updates
  16  
  17    Requires mysql client. Works on Windows and Unix.
  18  */
  19  
  20  // security - hide paths
  21  if (!defined('ADODB_DIR')) die();
  22  
  23  include_once(ADODB_DIR."/drivers/adodb-mysql.inc.php");
  24  
  25  
  26  class ADODB_mysqlt extends ADODB_mysql {
  27  	 var $databaseType = 'mysqlt';
  28  	 var $ansiOuter = true; // for Version 3.23.17 or later
  29  	 var $hasTransactions = true;
  30  	 var $autoRollback = true; // apparently mysql does not autorollback properly
  31  
  32  	function __construct()
  33  	 {
  34  	 global $ADODB_EXTENSION; if ($ADODB_EXTENSION) $this->rsPrefix .= 'ext_';
  35  	 }
  36  
  37  	 /* set transaction mode
  38  
  39  	 SET [GLOBAL | SESSION] TRANSACTION ISOLATION LEVEL
  40  { READ UNCOMMITTED | READ COMMITTED | REPEATABLE READ | SERIALIZABLE }
  41  
  42  	 */
  43  	function SetTransactionMode( $transaction_mode )
  44  	 {
  45  	 	 $this->_transmode  = $transaction_mode;
  46  	 	 if (empty($transaction_mode)) {
  47  	 	 	 $this->Execute('SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ');
  48  	 	 	 return;
  49  	 	 }
  50  	 	 if (!stristr($transaction_mode,'isolation')) $transaction_mode = 'ISOLATION LEVEL '.$transaction_mode;
  51  	 	 $this->Execute("SET SESSION TRANSACTION ".$transaction_mode);
  52  	 }
  53  
  54  	function BeginTrans()
  55  	 {
  56  	 	 if ($this->transOff) return true;
  57  	 	 $this->transCnt += 1;
  58  	 	 $this->Execute('SET AUTOCOMMIT=0');
  59  	 	 $this->Execute('BEGIN');
  60  	 	 return true;
  61  	 }
  62  
  63  	function CommitTrans($ok=true)
  64  	 {
  65  	 	 if ($this->transOff) return true;
  66  	 	 if (!$ok) return $this->RollbackTrans();
  67  
  68  	 	 if ($this->transCnt) $this->transCnt -= 1;
  69  	 	 $ok = $this->Execute('COMMIT');
  70  	 	 $this->Execute('SET AUTOCOMMIT=1');
  71  	 	 return $ok ? true : false;
  72  	 }
  73  
  74  	function RollbackTrans()
  75  	 {
  76  	 	 if ($this->transOff) return true;
  77  	 	 if ($this->transCnt) $this->transCnt -= 1;
  78  	 	 $ok = $this->Execute('ROLLBACK');
  79  	 	 $this->Execute('SET AUTOCOMMIT=1');
  80  	 	 return $ok ? true : false;
  81  	 }
  82  
  83  	function RowLock($tables,$where='',$col='1 as adodbignore')
  84  	 {
  85  	 	 if ($this->transCnt==0) $this->BeginTrans();
  86  	 	 if ($where) $where = ' where '.$where;
  87  	 	 $rs = $this->Execute("select $col from $tables $where for update");
  88  	 	 return !empty($rs);
  89  	 }
  90  
  91  }
  92  
  93  class ADORecordSet_mysqlt extends ADORecordSet_mysql{
  94  	 var $databaseType = "mysqlt";
  95  
  96  	function __construct($queryID,$mode=false)
  97  	 {
  98  	 	 if ($mode === false) {
  99  	 	 	 global $ADODB_FETCH_MODE;
 100  	 	 	 $mode = $ADODB_FETCH_MODE;
 101  	 	 }
 102  
 103  	 	 switch ($mode)
 104  	 	 {
 105  	 	 case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break;
 106  	 	 case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break;
 107  
 108  	 	 case ADODB_FETCH_DEFAULT:
 109  	 	 case ADODB_FETCH_BOTH:
 110  	 	 default: $this->fetchMode = MYSQL_BOTH; break;
 111  	 	 }
 112  
 113  	 	 $this->adodbFetchMode = $mode;
 114  	 	 parent::__construct($queryID);
 115  	 }
 116  
 117  	function MoveNext()
 118  	 {
 119  	 	 if (@$this->fields = mysql_fetch_array($this->_queryID,$this->fetchMode)) {
 120  	 	 	 $this->_currentRow += 1;
 121  	 	 	 return true;
 122  	 	 }
 123  	 	 if (!$this->EOF) {
 124  	 	 	 $this->_currentRow += 1;
 125  	 	 	 $this->EOF = true;
 126  	 	 }
 127  	 	 return false;
 128  	 }
 129  }
 130  
 131  class ADORecordSet_ext_mysqlt extends ADORecordSet_mysqlt {
 132  
 133  	function MoveNext()
 134  	 {
 135  	 	 return adodb_movenext($this);
 136  	 }
 137  }