egroupware/phpgwapi/inc/adodb/drivers/adodb-mysqlt.inc.php

142 lines
3.2 KiB
PHP
Raw Normal View History

2003-10-19 21:05:23 +02:00
<?php
/*
2005-09-26 12:12:10 +02:00
V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
2003-10-19 21:05:23 +02:00
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 8.
MySQL code that supports transactions. For MySQL 3.23 or later.
Code from James Poon <jpoon88@yahoo.com>
Requires mysql client. Works on Windows and Unix.
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
2003-10-19 21:05:23 +02:00
include_once(ADODB_DIR."/drivers/adodb-mysql.inc.php");
class ADODB_mysqlt extends ADODB_mysql {
var $databaseType = 'mysqlt';
var $ansiOuter = true; // for Version 3.23.17 or later
var $hasTransactions = true;
var $autoRollback = true; // apparently mysql does not autorollback properly
2003-10-19 21:05:23 +02:00
2004-08-02 10:30:47 +02:00
function ADODB_mysqlt()
{
global $ADODB_EXTENSION; if ($ADODB_EXTENSION) $this->rsPrefix .= 'ext_';
}
2003-10-19 21:05:23 +02:00
function BeginTrans()
{
if ($this->transOff) return true;
$this->transCnt += 1;
$this->Execute('SET AUTOCOMMIT=0');
$this->Execute('BEGIN');
return true;
}
function CommitTrans($ok=true)
{
if ($this->transOff) return true;
if (!$ok) return $this->RollbackTrans();
if ($this->transCnt) $this->transCnt -= 1;
$this->Execute('COMMIT');
$this->Execute('SET AUTOCOMMIT=1');
return true;
}
function RollbackTrans()
{
if ($this->transOff) return true;
if ($this->transCnt) $this->transCnt -= 1;
$this->Execute('ROLLBACK');
$this->Execute('SET AUTOCOMMIT=1');
return true;
}
function RowLock($tables,$where,$flds='1 as ignored')
2005-09-26 12:12:10 +02:00
{
if ($this->transCnt==0) $this->BeginTrans();
if (empty($where)) {
$qry = "select $flds from $tables for update";
} else {
$qry = "select $flds from $tables where $where for update";
}
return $this->GetOne($qry);
2005-09-26 12:12:10 +02:00
}
2003-10-19 21:05:23 +02:00
}
class ADORecordSet_mysqlt extends ADORecordSet_mysql{
var $databaseType = "mysqlt";
2004-08-02 10:30:47 +02:00
function ADORecordSet_mysqlt($queryID,$mode=false)
{
if ($mode === false) {
global $ADODB_FETCH_MODE;
$mode = $ADODB_FETCH_MODE;
}
2005-09-26 12:12:10 +02:00
2004-08-02 10:30:47 +02:00
switch ($mode)
{
case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break;
case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break;
2005-09-26 12:12:10 +02:00
2004-08-02 10:30:47 +02:00
case ADODB_FETCH_DEFAULT:
2005-09-26 12:12:10 +02:00
case ADODB_FETCH_BOTH:
default: $this->fetchMode = MYSQL_BOTH; break;
2004-08-02 10:30:47 +02:00
}
2005-09-26 12:12:10 +02:00
$this->adodbFetchMode = $mode;
2004-08-02 10:30:47 +02:00
$this->ADORecordSet($queryID);
2003-10-19 21:05:23 +02:00
}
2004-08-02 10:30:47 +02:00
function MoveNext()
{
2005-09-26 12:12:10 +02:00
if (@$this->fields = mysql_fetch_array($this->_queryID,$this->fetchMode)) {
2004-08-02 10:30:47 +02:00
$this->_currentRow += 1;
return true;
}
if (!$this->EOF) {
$this->_currentRow += 1;
$this->EOF = true;
}
2003-10-19 21:05:23 +02:00
return false;
2004-08-02 10:30:47 +02:00
}
}
class ADORecordSet_ext_mysqlt extends ADORecordSet_mysqlt {
2005-09-26 12:12:10 +02:00
function ADORecordSet_ext_mysqlt($queryID,$mode=false)
2004-08-02 10:30:47 +02:00
{
if ($mode === false) {
global $ADODB_FETCH_MODE;
$mode = $ADODB_FETCH_MODE;
}
switch ($mode)
{
case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break;
case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break;
2005-09-26 12:12:10 +02:00
2004-08-02 10:30:47 +02:00
case ADODB_FETCH_DEFAULT:
2005-09-26 12:12:10 +02:00
case ADODB_FETCH_BOTH:
default:
$this->fetchMode = MYSQL_BOTH; break;
2004-08-02 10:30:47 +02:00
}
2005-09-26 12:12:10 +02:00
$this->adodbFetchMode = $mode;
2004-08-02 10:30:47 +02:00
$this->ADORecordSet($queryID);
}
function MoveNext()
{
return adodb_movenext($this);
}
2003-10-19 21:05:23 +02:00
}
2004-08-02 10:30:47 +02:00
?>