1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-13 01:24:06 +02:00

refactoring in drivers

This commit is contained in:
David Grudl
2008-09-04 18:18:58 +00:00
parent 52d2ecf5b0
commit f935968aa7
5 changed files with 43 additions and 83 deletions

View File

@@ -132,7 +132,8 @@ class DibiPdoDriver extends /*Nette::*/Object implements IDibiDriver
$this->affectedRows = $this->connection->exec($sql);
if ($this->affectedRows === FALSE) {
$this->throwException($sql);
$err = $this->connection->errorInfo();
throw new DibiDriverException("SQLSTATE[$err[0]]: $err[2]", $err[1], $sql);
}
return NULL;
@@ -142,7 +143,8 @@ class DibiPdoDriver extends /*Nette::*/Object implements IDibiDriver
$this->affectedRows = FALSE;
if ($this->resultSet === FALSE) {
$this->throwException($sql);
$err = $this->connection->errorInfo();
throw new DibiDriverException("SQLSTATE[$err[0]]: $err[2]", $err[1], $sql);
}
return clone $this;
@@ -183,7 +185,8 @@ class DibiPdoDriver extends /*Nette::*/Object implements IDibiDriver
public function begin()
{
if (!$this->connection->beginTransaction()) {
$this->throwException();
$err = $this->connection->errorInfo();
throw new DibiDriverException("SQLSTATE[$err[0]]: $err[2]", $err[1]);
}
}
@@ -197,7 +200,8 @@ class DibiPdoDriver extends /*Nette::*/Object implements IDibiDriver
public function commit()
{
if (!$this->connection->commit()) {
$this->throwException();
$err = $this->connection->errorInfo();
throw new DibiDriverException("SQLSTATE[$err[0]]: $err[2]", $err[1]);
}
}
@@ -211,7 +215,8 @@ class DibiPdoDriver extends /*Nette::*/Object implements IDibiDriver
public function rollback()
{
if (!$this->connection->rollBack()) {
$this->throwException();
$err = $this->connection->errorInfo();
throw new DibiDriverException("SQLSTATE[$err[0]]: $err[2]", $err[1]);
}
}
@@ -379,19 +384,6 @@ class DibiPdoDriver extends /*Nette::*/Object implements IDibiDriver
/**
* Converts database error to DibiDriverException.
*
* @throws DibiDriverException
*/
protected function throwException($sql = NULL)
{
$err = $this->connection->errorInfo();
throw new DibiDriverException("SQLSTATE[$err[0]]: $err[2]", $err[1], $sql);
}
/**
* Returns the connection resource.
*