[ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 <?php 2 3 /* 4 V4.65 22 July 2005 (c) 2000-2005 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 function RowLock($tables,$where,$flds='1 as ignored') 63 { 64 if ($this->transCnt==0) $this->BeginTrans(); 65 if (empty($where)) { 66 $qry = "select $flds from $tables for update"; 67 } else { 68 $qry = "select $flds from $tables where $where for update"; 69 } 70 return $this->GetOne($qry); 71 } 72 73 } 74 75 class ADORecordSet_mysqlt extends ADORecordSet_mysql{ 76 var $databaseType = "mysqlt"; 77 78 function ADORecordSet_mysqlt($queryID,$mode=false) 79 { 80 if ($mode === false) { 81 global $ADODB_FETCH_MODE; 82 $mode = $ADODB_FETCH_MODE; 83 } 84 85 switch ($mode) 86 { 87 case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break; 88 case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break; 89 90 case ADODB_FETCH_DEFAULT: 91 case ADODB_FETCH_BOTH: 92 default: $this->fetchMode = MYSQL_BOTH; break; 93 } 94 95 $this->adodbFetchMode = $mode; 96 $this->ADORecordSet($queryID); 97 } 98 99 function MoveNext() 100 { 101 if (@$this->fields = mysql_fetch_array($this->_queryID,$this->fetchMode)) { 102 $this->_currentRow += 1; 103 return true; 104 } 105 if (!$this->EOF) { 106 $this->_currentRow += 1; 107 $this->EOF = true; 108 } 109 return false; 110 } 111 } 112 113 class ADORecordSet_ext_mysqlt extends ADORecordSet_mysqlt { 114 115 function ADORecordSet_ext_mysqlt($queryID,$mode=false) 116 { 117 if ($mode === false) { 118 global $ADODB_FETCH_MODE; 119 $mode = $ADODB_FETCH_MODE; 120 } 121 switch ($mode) 122 { 123 case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break; 124 case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break; 125 126 case ADODB_FETCH_DEFAULT: 127 case ADODB_FETCH_BOTH: 128 default: 129 $this->fetchMode = MYSQL_BOTH; break; 130 } 131 $this->adodbFetchMode = $mode; 132 $this->ADORecordSet($queryID); 133 } 134 135 function MoveNext() 136 { 137 return adodb_movenext($this); 138 } 139 } 140 141 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 17:20:01 2007 | par Balluche grâce à PHPXref 0.7 |