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 39 and 311]

   1  <?php
   2  
   3  /*
   4  @version   v5.21.0  2021-02-27
   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 deprecated 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  	 /* set transaction mode
  33  
  34  	 SET [GLOBAL | SESSION] TRANSACTION ISOLATION LEVEL
  35  { READ UNCOMMITTED | READ COMMITTED | REPEATABLE READ | SERIALIZABLE }
  36  
  37  	 */
  38  	function SetTransactionMode( $transaction_mode )
  39  	 {
  40  	 	 $this->_transmode  = $transaction_mode;
  41  	 	 if (empty($transaction_mode)) {
  42  	 	 	 $this->Execute('SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ');
  43  	 	 	 return;
  44  	 	 }
  45  	 	 if (!stristr($transaction_mode,'isolation')) $transaction_mode = 'ISOLATION LEVEL '.$transaction_mode;
  46  	 	 $this->Execute("SET SESSION TRANSACTION ".$transaction_mode);
  47  	 }
  48  
  49  	function BeginTrans()
  50  	 {
  51  	 	 if ($this->transOff) return true;
  52  	 	 $this->transCnt += 1;
  53  	 	 $this->Execute('SET AUTOCOMMIT=0');
  54  	 	 $this->Execute('BEGIN');
  55  	 	 return true;
  56  	 }
  57  
  58  	function CommitTrans($ok=true)
  59  	 {
  60  	 	 if ($this->transOff) return true;
  61  	 	 if (!$ok) return $this->RollbackTrans();
  62  
  63  	 	 if ($this->transCnt) $this->transCnt -= 1;
  64  	 	 $ok = $this->Execute('COMMIT');
  65  	 	 $this->Execute('SET AUTOCOMMIT=1');
  66  	 	 return $ok ? true : false;
  67  	 }
  68  
  69  	function RollbackTrans()
  70  	 {
  71  	 	 if ($this->transOff) return true;
  72  	 	 if ($this->transCnt) $this->transCnt -= 1;
  73  	 	 $ok = $this->Execute('ROLLBACK');
  74  	 	 $this->Execute('SET AUTOCOMMIT=1');
  75  	 	 return $ok ? true : false;
  76  	 }
  77  
  78  	function RowLock($tables,$where='',$col='1 as adodbignore')
  79  	 {
  80  	 	 if ($this->transCnt==0) $this->BeginTrans();
  81  	 	 if ($where) $where = ' where '.$where;
  82  	 	 $rs = $this->Execute("select $col from $tables $where for update");
  83  	 	 return !empty($rs);
  84  	 }
  85  
  86  }
  87  
  88  class ADORecordSet_mysqlt extends ADORecordSet_mysql{
  89  	 var $databaseType = "mysqlt";
  90  
  91  	function __construct($queryID,$mode=false)
  92  	 {
  93  	 	 if ($mode === false) {
  94  	 	 	 global $ADODB_FETCH_MODE;
  95  	 	 	 $mode = $ADODB_FETCH_MODE;
  96  	 	 }
  97  
  98  	 	 switch ($mode)
  99  	 	 {
 100  	 	 case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break;
 101  	 	 case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break;
 102  
 103  	 	 case ADODB_FETCH_DEFAULT:
 104  	 	 case ADODB_FETCH_BOTH:
 105  	 	 default: $this->fetchMode = MYSQL_BOTH; break;
 106  	 	 }
 107  
 108  	 	 $this->adodbFetchMode = $mode;
 109  	 	 parent::__construct($queryID);
 110  	 }
 111  
 112  	function MoveNext()
 113  	 {
 114  	 	 if (@$this->fields = mysql_fetch_array($this->_queryID,$this->fetchMode)) {
 115  	 	 	 $this->_currentRow += 1;
 116  	 	 	 return true;
 117  	 	 }
 118  	 	 if (!$this->EOF) {
 119  	 	 	 $this->_currentRow += 1;
 120  	 	 	 $this->EOF = true;
 121  	 	 }
 122  	 	 return false;
 123  	 }
 124  }
 125  
 126  class ADORecordSet_ext_mysqlt extends ADORecordSet_mysqlt {
 127  
 128  	function MoveNext()
 129  	 {
 130  	 	 return adodb_movenext($this);
 131  	 }
 132  }