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    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 BeginTrans()
  36  	 {
  37  	 	 if ($this->transOff) return true;
  38  	 	 $this->transCnt += 1;
  39  	 	 $this->Execute('SET AUTOCOMMIT=0');
  40  	 	 $this->Execute('BEGIN');
  41  	 	 return true;
  42  	 }
  43  
  44  	function CommitTrans($ok=true)
  45  	 {
  46  	 	 if ($this->transOff) return true;
  47  	 	 if (!$ok) return $this->RollbackTrans();
  48  
  49  	 	 if ($this->transCnt) $this->transCnt -= 1;
  50  	 	 $this->Execute('COMMIT');
  51  	 	 $this->Execute('SET AUTOCOMMIT=1');
  52  	 	 return true;
  53  	 }
  54  
  55  	function RollbackTrans()
  56  	 {
  57  	 	 if ($this->transOff) return true;
  58  	 	 if ($this->transCnt) $this->transCnt -= 1;
  59  	 	 $this->Execute('ROLLBACK');
  60  	 	 $this->Execute('SET AUTOCOMMIT=1');
  61  	 	 return true;
  62  	 }
  63  
  64  	function RowLock($tables,$where='',$col='1 as adodbignore')
  65  	 {
  66  	 	 if ($this->transCnt==0) $this->BeginTrans();
  67  	 	 if ($where) $where = ' where '.$where;
  68  	 	 $rs = $this->Execute("select $col from $tables $where for update");
  69  	 	 return !empty($rs);
  70  	 }
  71  
  72  }
  73  
  74  class ADORecordSet_mysqlt extends ADORecordSet_mysql{
  75  	 var $databaseType = "mysqlt";
  76  
  77  	function __construct($queryID,$mode=false)
  78  	 {
  79  	 	 if ($mode === false) {
  80  	 	 	 global $ADODB_FETCH_MODE;
  81  	 	 	 $mode = $ADODB_FETCH_MODE;
  82  	 	 }
  83  
  84  	 	 switch ($mode)
  85  	 	 {
  86  	 	 case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break;
  87  	 	 case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break;
  88  
  89  	 	 case ADODB_FETCH_DEFAULT:
  90  	 	 case ADODB_FETCH_BOTH:
  91  	 	 default: $this->fetchMode = MYSQL_BOTH; break;
  92  	 	 }
  93  
  94  	 	 $this->adodbFetchMode = $mode;
  95  	 	 parent::__construct($queryID);
  96  	 }
  97  
  98  	function MoveNext()
  99  	 {
 100  	 	 if (@$this->fields = mysql_fetch_array($this->_queryID,$this->fetchMode)) {
 101  	 	 	 $this->_currentRow += 1;
 102  	 	 	 return true;
 103  	 	 }
 104  	 	 if (!$this->EOF) {
 105  	 	 	 $this->_currentRow += 1;
 106  	 	 	 $this->EOF = true;
 107  	 	 }
 108  	 	 return false;
 109  	 }
 110  }
 111  
 112  class ADORecordSet_ext_mysqlt extends ADORecordSet_mysqlt {
 113  
 114  	function MoveNext()
 115  	 {
 116  	 	 return adodb_movenext($this);
 117  	 }
 118  }