1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-04 13:17:58 +02:00

FirebirdDriver: removed usage of tryError & catchError (not tested!)

This commit is contained in:
David Grudl
2015-10-13 19:57:52 +02:00
parent ee4cd0d6ef
commit 1a027c75ab

View File

@@ -77,15 +77,11 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
'buffers' => 0, 'buffers' => 0,
]; ];
Dibi\DriverException::tryError();
if (empty($config['persistent'])) { if (empty($config['persistent'])) {
$this->connection = ibase_connect($config['database'], $config['username'], $config['password'], $config['charset'], $config['buffers']); // intentionally @ $this->connection = ibase_connect($config['database'], $config['username'], $config['password'], $config['charset'], $config['buffers']); // intentionally @
} else { } else {
$this->connection = ibase_pconnect($config['database'], $config['username'], $config['password'], $config['charset'], $config['buffers']); // intentionally @ $this->connection = ibase_pconnect($config['database'], $config['username'], $config['password'], $config['charset'], $config['buffers']); // intentionally @
} }
if (Dibi\DriverException::catchError($msg)) {
throw new Dibi\DriverException($msg, ibase_errcode());
}
if (!is_resource($this->connection)) { if (!is_resource($this->connection)) {
throw new Dibi\DriverException(ibase_errmsg(), ibase_errcode()); throw new Dibi\DriverException(ibase_errmsg(), ibase_errcode());
@@ -112,22 +108,17 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
*/ */
public function query($sql) public function query($sql)
{ {
Dibi\DriverException::tryError();
$resource = $this->inTransaction ? $this->transaction : $this->connection; $resource = $this->inTransaction ? $this->transaction : $this->connection;
$res = ibase_query($resource, $sql); $res = ibase_query($resource, $sql);
if (Dibi\DriverException::catchError($msg)) { if ($res === FALSE) {
if (ibase_errcode() == self::ERROR_EXCEPTION_THROWN) { if (ibase_errcode() == self::ERROR_EXCEPTION_THROWN) {
preg_match('/exception (\d+) (\w+) (.*)/i', ibase_errmsg(), $match); preg_match('/exception (\d+) (\w+) (.*)/i', ibase_errmsg(), $match);
throw new Dibi\ProcedureException($match[3], $match[1], $match[2], \dibi::$sql); throw new Dibi\ProcedureException($match[3], $match[1], $match[2], $sql);
} else { } else {
throw new Dibi\DriverException(ibase_errmsg(), ibase_errcode(), \dibi::$sql); throw new Dibi\DriverException(ibase_errmsg(), ibase_errcode(), $sql);
} }
}
if ($res === FALSE) {
throw new Dibi\DriverException(ibase_errmsg(), ibase_errcode(), $sql);
} elseif (is_resource($res)) { } elseif (is_resource($res)) {
return $this->createResultDriver($res); return $this->createResultDriver($res);
@@ -378,10 +369,9 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
*/ */
public function fetch($assoc) public function fetch($assoc)
{ {
Dibi\DriverException::tryError();
$result = $assoc ? ibase_fetch_assoc($this->resultSet, IBASE_TEXT) : ibase_fetch_row($this->resultSet, IBASE_TEXT); // intentionally @ $result = $assoc ? ibase_fetch_assoc($this->resultSet, IBASE_TEXT) : ibase_fetch_row($this->resultSet, IBASE_TEXT); // intentionally @
if (Dibi\DriverException::catchError($msg)) { if (ibase_errcode()) {
if (ibase_errcode() == self::ERROR_EXCEPTION_THROWN) { if (ibase_errcode() == self::ERROR_EXCEPTION_THROWN) {
preg_match('/exception (\d+) (\w+) (.*)/is', ibase_errmsg(), $match); preg_match('/exception (\d+) (\w+) (.*)/is', ibase_errmsg(), $match);
throw new Dibi\ProcedureException($match[3], $match[1], $match[2], \dibi::$sql); throw new Dibi\ProcedureException($match[3], $match[1], $match[2], \dibi::$sql);