Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 310 and 400] [Versions 311 and 400] [Versions 39 and 400]

   1  <?php
   2  /**
   3   * MySQL driver in transactional mode
   4   *
   5   * @deprecated
   6   *
   7   * This driver only supports the original MySQL driver in transactional mode. It
   8   * is deprecated in PHP version 5.5 and removed in PHP version 7. It is deprecated
   9   * as of ADOdb version 5.20.0. Use the mysqli driver instead, which supports both
  10   * transactional and non-transactional updates
  11   *
  12   * This file is part of ADOdb, a Database Abstraction Layer library for PHP.
  13   *
  14   * @package ADOdb
  15   * @link https://adodb.org Project's web site and documentation
  16   * @link https://github.com/ADOdb/ADOdb Source code and issue tracker
  17   *
  18   * The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
  19   * and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
  20   * any later version. This means you can use it in proprietary products.
  21   * See the LICENSE.md file distributed with this source code for details.
  22   * @license BSD-3-Clause
  23   * @license LGPL-2.1-or-later
  24   *
  25   * @copyright 2000-2013 John Lim
  26   * @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
  27   */
  28  
  29  // security - hide paths
  30  if (!defined('ADODB_DIR')) die();
  31  
  32  include_once(ADODB_DIR."/drivers/adodb-mysql.inc.php");
  33  
  34  
  35  class ADODB_mysqlt extends ADODB_mysql {
  36  	 var $databaseType = 'mysqlt';
  37  	 var $ansiOuter = true; // for Version 3.23.17 or later
  38  	 var $hasTransactions = true;
  39  	 var $autoRollback = true; // apparently mysql does not autorollback properly
  40  
  41  	 /* set transaction mode
  42  
  43  	 SET [GLOBAL | SESSION] TRANSACTION ISOLATION LEVEL
  44  { READ UNCOMMITTED | READ COMMITTED | REPEATABLE READ | SERIALIZABLE }
  45  
  46  	 */
  47  	function SetTransactionMode( $transaction_mode )
  48  	 {
  49  	 	 $this->_transmode  = $transaction_mode;
  50  	 	 if (empty($transaction_mode)) {
  51  	 	 	 $this->Execute('SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ');
  52  	 	 	 return;
  53  	 	 }
  54  	 	 if (!stristr($transaction_mode,'isolation')) $transaction_mode = 'ISOLATION LEVEL '.$transaction_mode;
  55  	 	 $this->Execute("SET SESSION TRANSACTION ".$transaction_mode);
  56  	 }
  57  
  58  	function BeginTrans()
  59  	 {
  60  	 	 if ($this->transOff) return true;
  61  	 	 $this->transCnt += 1;
  62  	 	 $this->Execute('SET AUTOCOMMIT=0');
  63  	 	 $this->Execute('BEGIN');
  64  	 	 return true;
  65  	 }
  66  
  67  	function CommitTrans($ok=true)
  68  	 {
  69  	 	 if ($this->transOff) return true;
  70  	 	 if (!$ok) return $this->RollbackTrans();
  71  
  72  	 	 if ($this->transCnt) $this->transCnt -= 1;
  73  	 	 $ok = $this->Execute('COMMIT');
  74  	 	 $this->Execute('SET AUTOCOMMIT=1');
  75  	 	 return $ok ? true : false;
  76  	 }
  77  
  78  	function RollbackTrans()
  79  	 {
  80  	 	 if ($this->transOff) return true;
  81  	 	 if ($this->transCnt) $this->transCnt -= 1;
  82  	 	 $ok = $this->Execute('ROLLBACK');
  83  	 	 $this->Execute('SET AUTOCOMMIT=1');
  84  	 	 return $ok ? true : false;
  85  	 }
  86  
  87  	function RowLock($tables,$where='',$col='1 as adodbignore')
  88  	 {
  89  	 	 if ($this->transCnt==0) $this->BeginTrans();
  90  	 	 if ($where) $where = ' where '.$where;
  91  	 	 $rs = $this->Execute("select $col from $tables $where for update");
  92  	 	 return !empty($rs);
  93  	 }
  94  
  95  }
  96  
  97  class ADORecordSet_mysqlt extends ADORecordSet_mysql{
  98  	 var $databaseType = "mysqlt";
  99  
 100  	function __construct($queryID,$mode=false)
 101  	 {
 102  	 	 if ($mode === false) {
 103  	 	 	 global $ADODB_FETCH_MODE;
 104  	 	 	 $mode = $ADODB_FETCH_MODE;
 105  	 	 }
 106  
 107  	 	 switch ($mode)
 108  	 	 {
 109  	 	 case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break;
 110  	 	 case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break;
 111  
 112  	 	 case ADODB_FETCH_DEFAULT:
 113  	 	 case ADODB_FETCH_BOTH:
 114  	 	 default: $this->fetchMode = MYSQL_BOTH; break;
 115  	 	 }
 116  
 117  	 	 $this->adodbFetchMode = $mode;
 118  	 	 parent::__construct($queryID);
 119  	 }
 120  
 121  	function MoveNext()
 122  	 {
 123  	 	 if (@$this->fields = mysql_fetch_array($this->_queryID,$this->fetchMode)) {
 124  	 	 	 $this->_currentRow += 1;
 125  	 	 	 return true;
 126  	 	 }
 127  	 	 if (!$this->EOF) {
 128  	 	 	 $this->_currentRow += 1;
 129  	 	 	 $this->EOF = true;
 130  	 	 }
 131  	 	 return false;
 132  	 }
 133  }
 134  
 135  class ADORecordSet_ext_mysqlt extends ADORecordSet_mysqlt {
 136  
 137  	function MoveNext()
 138  	 {
 139  	 	 return adodb_movenext($this);
 140  	 }
 141  }