PageRenderTime 59ms CodeModel.GetById 36ms RepoModel.GetById 1ms app.codeStats 0ms

/concreteOLD/libraries/3rdparty/adodb/drivers/adodb-mysqlt.inc.php

https://bitbucket.org/selfeky/xclusivescardwebsite
PHP | 155 lines | 112 code | 24 blank | 19 comment | 19 complexity | ba757eccef7209d8a3a59efda7321104 MD5 | raw file
  1. <?php
  2. /*
  3. V5.10 10 Nov 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). All rights reserved.
  4. Released under both BSD license and Lesser GPL library license.
  5. Whenever there is any discrepancy between the two licenses,
  6. the BSD license will take precedence.
  7. Set tabs to 8.
  8. MySQL code that supports transactions. For MySQL 3.23 or later.
  9. Code from James Poon <jpoon88@yahoo.com>
  10. Requires mysql client. Works on Windows and Unix.
  11. */
  12. // security - hide paths
  13. if (!defined('ADODB_DIR')) die();
  14. include_once(ADODB_DIR."/drivers/adodb-mysql.inc.php");
  15. class ADODB_mysqlt extends ADODB_mysql {
  16. var $databaseType = 'mysqlt';
  17. var $ansiOuter = true; // for Version 3.23.17 or later
  18. var $hasTransactions = true;
  19. var $autoRollback = true; // apparently mysql does not autorollback properly
  20. function ADODB_mysqlt()
  21. {
  22. global $ADODB_EXTENSION; if ($ADODB_EXTENSION) $this->rsPrefix .= 'ext_';
  23. }
  24. /* set transaction mode
  25. SET [GLOBAL | SESSION] TRANSACTION ISOLATION LEVEL
  26. { READ UNCOMMITTED | READ COMMITTED | REPEATABLE READ | SERIALIZABLE }
  27. */
  28. function SetTransactionMode( $transaction_mode )
  29. {
  30. $this->_transmode = $transaction_mode;
  31. if (empty($transaction_mode)) {
  32. $this->Execute('SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ');
  33. return;
  34. }
  35. if (!stristr($transaction_mode,'isolation')) $transaction_mode = 'ISOLATION LEVEL '.$transaction_mode;
  36. $this->Execute("SET SESSION TRANSACTION ".$transaction_mode);
  37. }
  38. function BeginTrans()
  39. {
  40. if ($this->transOff) return true;
  41. $this->transCnt += 1;
  42. $this->Execute('SET AUTOCOMMIT=0');
  43. $this->Execute('BEGIN');
  44. return true;
  45. }
  46. function CommitTrans($ok=true)
  47. {
  48. if ($this->transOff) return true;
  49. if (!$ok) return $this->RollbackTrans();
  50. if ($this->transCnt) $this->transCnt -= 1;
  51. $ok = $this->Execute('COMMIT');
  52. $this->Execute('SET AUTOCOMMIT=1');
  53. return $ok ? true : false;
  54. }
  55. function RollbackTrans()
  56. {
  57. if ($this->transOff) return true;
  58. if ($this->transCnt) $this->transCnt -= 1;
  59. $ok = $this->Execute('ROLLBACK');
  60. $this->Execute('SET AUTOCOMMIT=1');
  61. return $ok ? true : false;
  62. }
  63. function RowLock($tables,$where='',$col='1 as adodb_ignore')
  64. {
  65. if ($this->transCnt==0) $this->BeginTrans();
  66. if ($where) $where = ' where '.$where;
  67. $rs = $this->Execute("select $col from $tables $where for update");
  68. return !empty($rs);
  69. }
  70. }
  71. class ADORecordSet_mysqlt extends ADORecordSet_mysql{
  72. var $databaseType = "mysqlt";
  73. function ADORecordSet_mysqlt($queryID,$mode=false)
  74. {
  75. if ($mode === false) {
  76. global $ADODB_FETCH_MODE;
  77. $mode = $ADODB_FETCH_MODE;
  78. }
  79. switch ($mode)
  80. {
  81. case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break;
  82. case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break;
  83. case ADODB_FETCH_DEFAULT:
  84. case ADODB_FETCH_BOTH:
  85. default: $this->fetchMode = MYSQL_BOTH; break;
  86. }
  87. $this->adodbFetchMode = $mode;
  88. $this->ADORecordSet($queryID);
  89. }
  90. function MoveNext()
  91. {
  92. if (@$this->fields = mysql_fetch_array($this->_queryID,$this->fetchMode)) {
  93. $this->_currentRow += 1;
  94. return true;
  95. }
  96. if (!$this->EOF) {
  97. $this->_currentRow += 1;
  98. $this->EOF = true;
  99. }
  100. return false;
  101. }
  102. }
  103. class ADORecordSet_ext_mysqlt extends ADORecordSet_mysqlt {
  104. function ADORecordSet_ext_mysqlt($queryID,$mode=false)
  105. {
  106. if ($mode === false) {
  107. global $ADODB_FETCH_MODE;
  108. $mode = $ADODB_FETCH_MODE;
  109. }
  110. switch ($mode)
  111. {
  112. case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break;
  113. case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break;
  114. case ADODB_FETCH_DEFAULT:
  115. case ADODB_FETCH_BOTH:
  116. default:
  117. $this->fetchMode = MYSQL_BOTH; break;
  118. }
  119. $this->adodbFetchMode = $mode;
  120. $this->ADORecordSet($queryID);
  121. }
  122. function MoveNext()
  123. {
  124. return adodb_movenext($this);
  125. }
  126. }
  127. ?>