fix Row size too large error, change varchar(255) to TEXT
[openemr.git] / gacl / adodb / drivers / adodb-mysqlt.inc.php
blob452a76d06027fef18d279a67b24e5df9c455da94
1 <?php
3 /*
4 V4.92a 29 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). 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.
8 Set tabs to 8.
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_';
33 /* set transaction mode
35 SET [GLOBAL | SESSION] TRANSACTION ISOLATION LEVEL
36 { READ UNCOMMITTED | READ COMMITTED | REPEATABLE READ | SERIALIZABLE }
39 function SetTransactionMode( $transaction_mode )
41 $this->_transmode = $transaction_mode;
42 if (empty($transaction_mode)) {
43 $this->Execute('SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ');
44 return;
46 if (!stristr($transaction_mode,'isolation')) $transaction_mode = 'ISOLATION LEVEL '.$transaction_mode;
47 $this->Execute("SET SESSION TRANSACTION ".$transaction_mode);
50 function BeginTrans()
52 if ($this->transOff) return true;
53 $this->transCnt += 1;
54 $this->Execute('SET AUTOCOMMIT=0');
55 $this->Execute('BEGIN');
56 return true;
59 function CommitTrans($ok=true)
61 if ($this->transOff) return true;
62 if (!$ok) return $this->RollbackTrans();
64 if ($this->transCnt) $this->transCnt -= 1;
65 $this->Execute('COMMIT');
66 $this->Execute('SET AUTOCOMMIT=1');
67 return true;
70 function RollbackTrans()
72 if ($this->transOff) return true;
73 if ($this->transCnt) $this->transCnt -= 1;
74 $this->Execute('ROLLBACK');
75 $this->Execute('SET AUTOCOMMIT=1');
76 return true;
79 function RowLock($tables,$where='',$flds='1 as adodb_ignore')
81 if ($this->transCnt==0) $this->BeginTrans();
82 if ($where) $where = ' where '.$where;
83 $rs =& $this->Execute("select $flds from $tables $where for update");
84 return !empty($rs);
89 class ADORecordSet_mysqlt extends ADORecordSet_mysql{
90 var $databaseType = "mysqlt";
92 function ADORecordSet_mysqlt($queryID,$mode=false)
94 if ($mode === false) {
95 global $ADODB_FETCH_MODE;
96 $mode = $ADODB_FETCH_MODE;
99 switch ($mode)
101 case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break;
102 case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break;
104 case ADODB_FETCH_DEFAULT:
105 case ADODB_FETCH_BOTH:
106 default: $this->fetchMode = MYSQL_BOTH; break;
109 $this->adodbFetchMode = $mode;
110 $this->ADORecordSet($queryID);
113 function MoveNext()
115 if (@$this->fields = mysql_fetch_array($this->_queryID,$this->fetchMode)) {
116 $this->_currentRow += 1;
117 return true;
119 if (!$this->EOF) {
120 $this->_currentRow += 1;
121 $this->EOF = true;
123 return false;
127 class ADORecordSet_ext_mysqlt extends ADORecordSet_mysqlt {
129 function ADORecordSet_ext_mysqlt($queryID,$mode=false)
131 if ($mode === false) {
132 global $ADODB_FETCH_MODE;
133 $mode = $ADODB_FETCH_MODE;
135 switch ($mode)
137 case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break;
138 case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break;
140 case ADODB_FETCH_DEFAULT:
141 case ADODB_FETCH_BOTH:
142 default:
143 $this->fetchMode = MYSQL_BOTH; break;
145 $this->adodbFetchMode = $mode;
146 $this->ADORecordSet($queryID);
149 function MoveNext()
151 return adodb_movenext($this);