Commit a3becb14 authored by Benjamin Eberlei's avatar Benjamin Eberlei

DBAL-61 - Merge patch from milokment to align Oracle Transaction behavior to...

DBAL-61 - Merge patch from milokment to align Oracle Transaction behavior to other drivers (Auto-Commit ON when not in an explicit transation).
parents 0e61c37c d9b77d89
......@@ -28,6 +28,8 @@ class OCI8Connection implements \Doctrine\DBAL\Driver\Connection
{
private $_dbh;
private $_executeMode = OCI_COMMIT_ON_SUCCESS;
/**
* Create a Connection to an Oracle Database using oci8 extension.
*
......@@ -37,9 +39,13 @@ class OCI8Connection implements \Doctrine\DBAL\Driver\Connection
*/
public function __construct($username, $password, $db)
{
if (!defined('OCI_NO_AUTO_COMMIT')) {
define('OCI_NO_AUTO_COMMIT', 0);
}
$this->_dbh = @oci_connect($username, $password, $db);
if (!$this->_dbh) {
throw new OCI8Exception($this->errorInfo());
throw OCI8Exception::fromErrorInfo(oci_error());
}
}
......@@ -51,7 +57,7 @@ class OCI8Connection implements \Doctrine\DBAL\Driver\Connection
*/
public function prepare($prepareString)
{
return new OCI8Statement($this->_dbh, $prepareString);
return new OCI8Statement($this->_dbh, $prepareString, $this->_executeMode);
}
/**
......@@ -108,6 +114,7 @@ class OCI8Connection implements \Doctrine\DBAL\Driver\Connection
*/
public function beginTransaction()
{
$this->_executeMode = OCI_NO_AUTO_COMMIT;
return true;
}
......@@ -120,6 +127,7 @@ class OCI8Connection implements \Doctrine\DBAL\Driver\Connection
if (!oci_commit($this->_dbh)) {
throw OCI8Exception::fromErrorInfo($this->errorInfo());
}
$this->_executeMode = OCI_COMMIT_ON_SUCCESS;
return true;
}
......@@ -132,6 +140,7 @@ class OCI8Connection implements \Doctrine\DBAL\Driver\Connection
if (!oci_rollback($this->_dbh)) {
throw OCI8Exception::fromErrorInfo($this->errorInfo());
}
$this->_executeMode = OCI_COMMIT_ON_SUCCESS;
return true;
}
......@@ -148,4 +157,4 @@ class OCI8Connection implements \Doctrine\DBAL\Driver\Connection
{
return oci_error($this->_dbh);
}
}
\ No newline at end of file
}
......@@ -31,6 +31,7 @@ class OCI8Statement implements \Doctrine\DBAL\Driver\Statement
{
/** Statement handle. */
private $_sth;
private $_executeMode;
private static $_PARAM = ':param';
private static $fetchStyleMap = array(
PDO::FETCH_BOTH => OCI_BOTH,
......@@ -45,11 +46,12 @@ class OCI8Statement implements \Doctrine\DBAL\Driver\Statement
* @param resource $dbh The connection handle.
* @param string $statement The SQL statement.
*/
public function __construct($dbh, $statement)
public function __construct($dbh, $statement, $executeMode)
{
list($statement, $paramMap) = self::convertPositionalToNamedPlaceholders($statement);
$this->_sth = oci_parse($dbh, $statement);
$this->_paramMap = $paramMap;
$this->_executeMode = $executeMode;
}
/**
......@@ -164,7 +166,7 @@ class OCI8Statement implements \Doctrine\DBAL\Driver\Statement
}
}
$ret = @oci_execute($this->_sth, OCI_DEFAULT);
$ret = @oci_execute($this->_sth, $this->_executeMode);
if ( ! $ret) {
throw OCI8Exception::fromErrorInfo($this->errorInfo());
}
......@@ -215,4 +217,4 @@ class OCI8Statement implements \Doctrine\DBAL\Driver\Statement
{
return oci_num_rows($this->_sth);
}
}
\ No newline at end of file
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment