[2] | 1 | <?php |
---|
| 2 | |
---|
| 3 | /* |
---|
| 4 | V4.51 29 July 2004 (c) 2000-2004 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. |
---|
| 9 | |
---|
| 10 | MySQL code that supports transactions. For MySQL 3.23 or later. |
---|
| 11 | Code from James Poon <jpoon88@yahoo.com> |
---|
| 12 | |
---|
| 13 | Requires mysql client. Works on Windows and Unix. |
---|
| 14 | */ |
---|
| 15 | |
---|
| 16 | // security - hide paths |
---|
| 17 | if (!defined('ADODB_DIR')) die(); |
---|
| 18 | |
---|
| 19 | include_once(ADODB_DIR."/drivers/adodb-mysql.inc.php"); |
---|
| 20 | |
---|
| 21 | |
---|
| 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 |
---|
| 27 | |
---|
| 28 | function ADODB_mysqlt() |
---|
| 29 | { |
---|
| 30 | global $ADODB_EXTENSION; if ($ADODB_EXTENSION) $this->rsPrefix .= 'ext_'; |
---|
| 31 | } |
---|
| 32 | |
---|
| 33 | function BeginTrans() |
---|
| 34 | { |
---|
| 35 | if ($this->transOff) return true; |
---|
| 36 | $this->transCnt += 1; |
---|
| 37 | $this->Execute('SET AUTOCOMMIT=0'); |
---|
| 38 | $this->Execute('BEGIN'); |
---|
| 39 | return true; |
---|
| 40 | } |
---|
| 41 | |
---|
| 42 | function CommitTrans($ok=true) |
---|
| 43 | { |
---|
| 44 | if ($this->transOff) return true; |
---|
| 45 | if (!$ok) return $this->RollbackTrans(); |
---|
| 46 | |
---|
| 47 | if ($this->transCnt) $this->transCnt -= 1; |
---|
| 48 | $this->Execute('COMMIT'); |
---|
| 49 | $this->Execute('SET AUTOCOMMIT=1'); |
---|
| 50 | return true; |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | function RollbackTrans() |
---|
| 54 | { |
---|
| 55 | if ($this->transOff) return true; |
---|
| 56 | if ($this->transCnt) $this->transCnt -= 1; |
---|
| 57 | $this->Execute('ROLLBACK'); |
---|
| 58 | $this->Execute('SET AUTOCOMMIT=1'); |
---|
| 59 | return true; |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | class ADORecordSet_mysqlt extends ADORecordSet_mysql{ |
---|
| 65 | var $databaseType = "mysqlt"; |
---|
| 66 | |
---|
| 67 | function ADORecordSet_mysqlt($queryID,$mode=false) |
---|
| 68 | { |
---|
| 69 | if ($mode === false) { |
---|
| 70 | global $ADODB_FETCH_MODE; |
---|
| 71 | $mode = $ADODB_FETCH_MODE; |
---|
| 72 | } |
---|
| 73 | switch ($mode) |
---|
| 74 | { |
---|
| 75 | case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break; |
---|
| 76 | case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break; |
---|
| 77 | default: |
---|
| 78 | case ADODB_FETCH_DEFAULT: |
---|
| 79 | case ADODB_FETCH_BOTH:$this->fetchMode = MYSQL_BOTH; break; |
---|
| 80 | } |
---|
| 81 | |
---|
| 82 | $this->ADORecordSet($queryID); |
---|
| 83 | } |
---|
| 84 | |
---|
| 85 | function MoveNext() |
---|
| 86 | { |
---|
| 87 | if (@$this->fields =& mysql_fetch_array($this->_queryID,$this->fetchMode)) { |
---|
| 88 | $this->_currentRow += 1; |
---|
| 89 | return true; |
---|
| 90 | } |
---|
| 91 | if (!$this->EOF) { |
---|
| 92 | $this->_currentRow += 1; |
---|
| 93 | $this->EOF = true; |
---|
| 94 | } |
---|
| 95 | return false; |
---|
| 96 | } |
---|
| 97 | } |
---|
| 98 | |
---|
| 99 | class ADORecordSet_ext_mysqlt extends ADORecordSet_mysqlt { |
---|
| 100 | |
---|
| 101 | function ADORecordSet_ext_mysqli($queryID,$mode=false) |
---|
| 102 | { |
---|
| 103 | if ($mode === false) { |
---|
| 104 | global $ADODB_FETCH_MODE; |
---|
| 105 | $mode = $ADODB_FETCH_MODE; |
---|
| 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 | default: |
---|
| 112 | case ADODB_FETCH_DEFAULT: |
---|
| 113 | case ADODB_FETCH_BOTH:$this->fetchMode = MYSQL_BOTH; break; |
---|
| 114 | } |
---|
| 115 | |
---|
| 116 | $this->ADORecordSet($queryID); |
---|
| 117 | } |
---|
| 118 | |
---|
| 119 | function MoveNext() |
---|
| 120 | { |
---|
| 121 | return adodb_movenext($this); |
---|
| 122 | } |
---|
| 123 | } |
---|
| 124 | |
---|
| 125 | ?> |
---|