1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-06 14:16:39 +02:00

DibiConnection: inTransaction() is back, implemented in drivers

This commit is contained in:
David Grudl
2010-01-11 16:56:54 +01:00
parent c37475838f
commit d61bd79982
13 changed files with 131 additions and 3 deletions

View File

@@ -156,7 +156,6 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver
public function getInsertId($sequence) public function getInsertId($sequence)
{ {
return ibase_gen_id($sequence, 0, $this->connection); return ibase_gen_id($sequence, 0, $this->connection);
//throw new NotSupportedException('Firebird/InterBase does not support autoincrementing.');
} }
@@ -220,6 +219,17 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver
/**
* Is in transaction?
* @return bool
*/
public function inTransaction()
{
return $this->inTransaction;
}
/** /**
* Returns the connection resource. * Returns the connection resource.
* @return resource * @return resource

View File

@@ -170,6 +170,17 @@ class DibiMsSqlDriver extends DibiObject implements IDibiDriver
/**
* Is in transaction?
* @return bool
*/
public function inTransaction()
{
throw new NotSupportedException('MSSQL driver does not support transaction testing.');
}
/** /**
* Returns the connection resource. * Returns the connection resource.
* @return mixed * @return mixed

View File

@@ -168,6 +168,17 @@ class DibiMsSql2005Driver extends DibiObject implements IDibiDriver
/**
* Is in transaction?
* @return bool
*/
public function inTransaction()
{
throw new NotSupportedException('MSSQL 2005 driver does not support transaction testing.');
}
/** /**
* Returns the connection resource. * Returns the connection resource.
* @return mixed * @return mixed

View File

@@ -247,6 +247,17 @@ class DibiMySqlDriver extends DibiObject implements IDibiDriver
/**
* Is in transaction?
* @return bool
*/
public function inTransaction()
{
return (bool) mysql_fetch_field(mysql_query('SELECT @@autocommit', $this->connection));
}
/** /**
* Returns the connection resource. * Returns the connection resource.
* @return mixed * @return mixed

View File

@@ -231,6 +231,17 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver
/**
* Is in transaction?
* @return bool
*/
public function inTransaction()
{
return (bool) mysqli_fetch_field_direct(mysqli_query($this->connection, 'SELECT @@autocommit'), 0);
}
/** /**
* Returns the connection resource. * Returns the connection resource.
* @return mysqli * @return mysqli

View File

@@ -178,6 +178,17 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver
/**
* Is in transaction?
* @return bool
*/
public function inTransaction()
{
return (bool) odbc_autocommit($this->connection);
}
/** /**
* Returns the connection resource. * Returns the connection resource.
* @return mixed * @return mixed

View File

@@ -186,6 +186,17 @@ class DibiOracleDriver extends DibiObject implements IDibiDriver
/**
* Is in transaction?
* @return bool
*/
public function inTransaction()
{
throw new NotSupportedException('Oracle driver does not support transaction testing.');
}
/** /**
* Returns the connection resource. * Returns the connection resource.
* @return mixed * @return mixed

View File

@@ -197,6 +197,17 @@ class DibiPdoDriver extends DibiObject implements IDibiDriver
/**
* Is in transaction?
* @return bool
*/
public function inTransaction()
{
return (bool) $this->connection->getAttribute(PDO::ATTR_AUTOCOMMIT);
}
/** /**
* Returns the connection resource. * Returns the connection resource.
* @return PDO * @return PDO

View File

@@ -207,6 +207,17 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver
/**
* Is in transaction?
* @return bool
*/
public function inTransaction()
{
throw new NotSupportedException('PostgreSQL driver does not support transaction testing.');
}
/** /**
* Returns the connection resource. * Returns the connection resource.
* @return mixed * @return mixed

View File

@@ -193,6 +193,17 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver
/**
* Is in transaction?
* @return bool
*/
public function inTransaction()
{
throw new NotSupportedException('SQLite driver does not support transaction testing.');
}
/** /**
* Returns the connection resource. * Returns the connection resource.
* @return mixed * @return mixed

View File

@@ -183,6 +183,17 @@ class DibiSqlite3Driver extends DibiObject implements IDibiDriver
/**
* Is in transaction?
* @return bool
*/
public function inTransaction()
{
throw new NotSupportedException('SQLite3 driver does not support transaction testing.');
}
/** /**
* Returns the connection resource. * Returns the connection resource.
* @return mixed * @return mixed

View File

@@ -452,11 +452,13 @@ class DibiConnection extends DibiObject
/** /**
* @deprecated * Is in transaction?
* @return bool
*/ */
public function inTransaction() public function inTransaction()
{ {
trigger_error('Deprecated: use "SELECT @@autocommit" query instead.', E_USER_WARNING); $this->connect();
return $this->driver->inTransaction();
} }

View File

@@ -145,6 +145,12 @@ interface IDibiDriver
*/ */
function rollback($savepoint = NULL); function rollback($savepoint = NULL);
/**
* Is in transaction?
* @return bool
*/
function inTransaction();
/** /**
* Returns the connection resource. * Returns the connection resource.
* @return mixed * @return mixed