Commit d9b77d89 authored by Miloslav Kmet's avatar Miloslav Kmet

Make transactions in OCI8 driver compatible with other drivers.

parent fc28444a
......@@ -30,6 +30,8 @@ class OCI8Connection implements \Doctrine\DBAL\Driver\Connection
{
private $_dbh;
protected $_executeMode = OCI_COMMIT_ON_SUCCESS;
public function __construct($username, $password, $db)
{
$this->_dbh = @oci_connect($username, $password, $db);
......@@ -40,7 +42,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);
}
public function query()
......@@ -72,6 +74,7 @@ class OCI8Connection implements \Doctrine\DBAL\Driver\Connection
public function beginTransaction()
{
$this->_executeMode = OCI_NO_AUTO_COMMIT;
return true;
}
......@@ -80,6 +83,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;
}
......@@ -88,6 +92,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;
}
......
......@@ -33,6 +33,7 @@ class OCI8Statement implements \Doctrine\DBAL\Driver\Statement
{
/** Statement handle. */
private $_sth;
private $_executeMode;
private $_paramCounter = 0;
private static $_PARAM = ':param';
private static $fetchStyleMap = array(
......@@ -48,9 +49,10 @@ 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)
{
$this->_sth = oci_parse($dbh, $this->_convertPositionalToNamedPlaceholders($statement));
$this->_executeMode = $executeMode;
}
/**
......@@ -146,7 +148,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());
}
......
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