diff --git a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php index 7ab8d117b..66a02e73d 100644 --- a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php +++ b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php @@ -32,7 +32,10 @@ class OCI8Connection implements \Doctrine\DBAL\Driver\Connection public function __construct($username, $password, $db) { - $this->_dbh = oci_connect($username, $password, $db); + $this->_dbh = @oci_connect($username, $password, $db); + if (!$this->_dbh) { + throw new OCI8Exception($this->errorInfo()); + } } public function prepare($prepareString) @@ -74,12 +77,18 @@ class OCI8Connection implements \Doctrine\DBAL\Driver\Connection public function commit() { - return oci_commit($this->_dbh); + if (!oci_commit($this->_dbh)) { + throw OCI8Exception::fromErrorInfo($this->errorInfo()); + } + return true; } public function rollBack() { - return oci_rollback($this->_dbh); + if (!oci_rollback($this->_dbh)) { + throw OCI8Exception::fromErrorInfo($this->errorInfo()); + } + return true; } public function errorCode() diff --git a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Exception.php b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Exception.php new file mode 100644 index 000000000..66fe615a1 --- /dev/null +++ b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Exception.php @@ -0,0 +1,30 @@ +. +*/ + +namespace Doctrine\DBAL\Driver\OCI8; + +class OCI8Exception extends \Exception +{ + static public function fromErrorInfo($error) + { + return new self($error['message'], $error['code']); + } +} diff --git a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php index 184f39e64..b4f3b586b 100644 --- a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php +++ b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php @@ -137,7 +137,11 @@ class OCI8Statement implements \Doctrine\DBAL\Driver\Statement } } - return oci_execute($this->_sth, OCI_DEFAULT); + $ret = @oci_execute($this->_sth, OCI_DEFAULT); + if (!$ret) { + throw OCI8Exception::fromErrorInfo($this->errorInfo()); + } + return $ret; } /**