4 V5.18 3 Sep 2012 (c) 2000-2012 John Lim (jlim#natsoft.com). All rights reserved.
5 Released under both BSD license and Lesser GPL library license.
6 Whenever there is any discrepancy between the two licenses,
7 the BSD license will take precedence.
10 MySQL code that supports transactions. For MySQL 3.23 or later.
11 Code from James Poon <jpoon88@yahoo.com>
13 Requires mysql client. Works on Windows and Unix.
16 // security - hide paths
17 if (!defined('ADODB_DIR')) die();
19 include_once(ADODB_DIR."/drivers/adodb-mysql.inc.php");
22 class ADODB_mysqlt extends ADODB_mysql {
23 var $databaseType = 'mysqlt';
24 var $ansiOuter = true; // for Version 3.23.17 or later
25 var $hasTransactions = true;
26 var $autoRollback = true; // apparently mysql does not autorollback properly
28 function ADODB_mysqlt()
30 global $ADODB_EXTENSION; if ($ADODB_EXTENSION) $this->rsPrefix .= 'ext_';
35 if ($this->transOff) return true;
37 $this->Execute('SET AUTOCOMMIT=0');
38 $this->Execute('BEGIN');
42 function CommitTrans($ok=true)
44 if ($this->transOff) return true;
45 if (!$ok) return $this->RollbackTrans();
47 if ($this->transCnt) $this->transCnt -= 1;
48 $this->Execute('COMMIT');
49 $this->Execute('SET AUTOCOMMIT=1');
53 function RollbackTrans()
55 if ($this->transOff) return true;
56 if ($this->transCnt) $this->transCnt -= 1;
57 $this->Execute('ROLLBACK');
58 $this->Execute('SET AUTOCOMMIT=1');
62 function RowLock($tables,$where='',$col='1 as adodbignore')
64 if ($this->transCnt==0) $this->BeginTrans();
65 if ($where) $where = ' where '.$where;
66 $rs = $this->Execute("select $col from $tables $where for update");
72 class ADORecordSet_mysqlt extends ADORecordSet_mysql{
73 var $databaseType = "mysqlt";
75 function ADORecordSet_mysqlt($queryID,$mode=false)
77 if ($mode === false) {
78 global $ADODB_FETCH_MODE;
79 $mode = $ADODB_FETCH_MODE;
84 case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break;
85 case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break;
87 case ADODB_FETCH_DEFAULT:
88 case ADODB_FETCH_BOTH:
89 default: $this->fetchMode = MYSQL_BOTH; break;
92 $this->adodbFetchMode = $mode;
93 $this->ADORecordSet($queryID);
98 if (@$this->fields = mysql_fetch_array($this->_queryID,$this->fetchMode)) {
99 $this->_currentRow += 1;
103 $this->_currentRow += 1;
110 class ADORecordSet_ext_mysqlt extends ADORecordSet_mysqlt {
112 function ADORecordSet_ext_mysqlt($queryID,$mode=false)
114 if ($mode === false) {
115 global $ADODB_FETCH_MODE;
116 $mode = $ADODB_FETCH_MODE;
120 case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break;
121 case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break;
123 case ADODB_FETCH_DEFAULT:
124 case ADODB_FETCH_BOTH:
126 $this->fetchMode = MYSQL_BOTH; break;
128 $this->adodbFetchMode = $mode;
129 $this->ADORecordSet($queryID);
134 return adodb_movenext($this);