Skip to content

Commit

Permalink
Fix autostart transaction when save lobs
Browse files Browse the repository at this point in the history
  • Loading branch information
kikimor committed Feb 10, 2017
1 parent 367b32c commit b4e705d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Oci8Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,15 @@ public function __construct($sth, Oci8 $connection, array $options = [])
public function execute($inputParams = null)
{
$mode = OCI_COMMIT_ON_SUCCESS;
if ($this->connection->inTransaction() || count($this->saveLobs) > 0 || count($this->writeLobs) > 0) {

$lobTransaction = false;
// Begin transaction, if lobs need save, but transaction was not started before.
if ((count($this->saveLobs) > 0 || count($this->writeLobs) > 0) && !$this->connection->inTransaction()) {
$this->connection->beginTransaction();
$lobTransaction = true;
}

if ($this->connection->inTransaction()) {
$mode = OCI_DEFAULT;
}

Expand Down Expand Up @@ -127,7 +135,7 @@ public function execute($inputParams = null)
throw new Oci8Exception($e['message'], $e['code']);
}

if (!$this->connection->inTransaction() && (count($this->saveLobs) > 0 || count($this->writeLobs) > 0)) {
if ($lobTransaction) {
return $this->connection->commit();
}

Expand Down

0 comments on commit b4e705d

Please sign in to comment.