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   * Portable MySQL driver
   4   *
   5   * @deprecated
   6   *
   7   * Extends the deprecated mysql driver, and was originally designed to be a
   8   * portable driver in the same manner as oci8po and mssqlpo. Its functionality
   9   * is exactly duplicated in the mysqlt driver, which is itself deprecated.
  10   * This driver will be removed in ADOdb version 6.0.0.
  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  	function BeginTrans()
  42  	 {
  43  	 	 if ($this->transOff) return true;
  44  	 	 $this->transCnt += 1;
  45  	 	 $this->Execute('SET AUTOCOMMIT=0');
  46  	 	 $this->Execute('BEGIN');
  47  	 	 return true;
  48  	 }
  49  
  50  	function CommitTrans($ok=true)
  51  	 {
  52  	 	 if ($this->transOff) return true;
  53  	 	 if (!$ok) return $this->RollbackTrans();
  54  
  55  	 	 if ($this->transCnt) $this->transCnt -= 1;
  56  	 	 $this->Execute('COMMIT');
  57  	 	 $this->Execute('SET AUTOCOMMIT=1');
  58  	 	 return true;
  59  	 }
  60  
  61  	function RollbackTrans()
  62  	 {
  63  	 	 if ($this->transOff) return true;
  64  	 	 if ($this->transCnt) $this->transCnt -= 1;
  65  	 	 $this->Execute('ROLLBACK');
  66  	 	 $this->Execute('SET AUTOCOMMIT=1');
  67  	 	 return true;
  68  	 }
  69  
  70  	function RowLock($tables,$where='',$col='1 as adodbignore')
  71  	 {
  72  	 	 if ($this->transCnt==0) $this->BeginTrans();
  73  	 	 if ($where) $where = ' where '.$where;
  74  	 	 $rs = $this->Execute("select $col from $tables $where for update");
  75  	 	 return !empty($rs);
  76  	 }
  77  
  78  }
  79  
  80  class ADORecordSet_mysqlt extends ADORecordSet_mysql{
  81  	 var $databaseType = "mysqlt";
  82  
  83  	function __construct($queryID,$mode=false)
  84  	 {
  85  	 	 if ($mode === false) {
  86  	 	 	 global $ADODB_FETCH_MODE;
  87  	 	 	 $mode = $ADODB_FETCH_MODE;
  88  	 	 }
  89  
  90  	 	 switch ($mode)
  91  	 	 {
  92  	 	 case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break;
  93  	 	 case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break;
  94  
  95  	 	 case ADODB_FETCH_DEFAULT:
  96  	 	 case ADODB_FETCH_BOTH:
  97  	 	 default: $this->fetchMode = MYSQL_BOTH; break;
  98  	 	 }
  99  
 100  	 	 $this->adodbFetchMode = $mode;
 101  	 	 parent::__construct($queryID);
 102  	 }
 103  
 104  	function MoveNext()
 105  	 {
 106  	 	 if (@$this->fields = mysql_fetch_array($this->_queryID,$this->fetchMode)) {
 107  	 	 	 $this->_currentRow += 1;
 108  	 	 	 return true;
 109  	 	 }
 110  	 	 if (!$this->EOF) {
 111  	 	 	 $this->_currentRow += 1;
 112  	 	 	 $this->EOF = true;
 113  	 	 }
 114  	 	 return false;
 115  	 }
 116  }
 117  
 118  class ADORecordSet_ext_mysqlt extends ADORecordSet_mysqlt {
 119  
 120  	function MoveNext()
 121  	 {
 122  	 	 return adodb_movenext($this);
 123  	 }
 124  }