Skip to content

Commit

Permalink
Support for transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
bpolaszek committed Jan 23, 2018
1 parent 0c31627 commit 2a366fa
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
15 changes: 15 additions & 0 deletions src/Contract/AdapterInterface.php
Expand Up @@ -20,4 +20,19 @@ public function getWrappedConnection();
* @return CredentialsInterface
*/
public function getCredentials(): CredentialsInterface;

/**
* Init a transaction.
*/
public function beginTransaction(): void;

/**
* Commit current transaction
*/
public function commit(): void;

/**
* Rollback current transaction
*/
public function rollback(): void;
}
6 changes: 3 additions & 3 deletions src/Model/Adapter/Mysqli/MysqliAdapter.php
Expand Up @@ -280,15 +280,15 @@ private function runStmt(Statement $stmt)
/**
* @inheritDoc
*/
public function beginTransaction()
public function beginTransaction(): void
{
$this->getWrappedConnection()->autocommit(false);
}

/**
* @inheritDoc
*/
public function commit()
public function commit(): void
{
$this->getWrappedConnection()->commit();
$this->getWrappedConnection()->autocommit(true);
Expand All @@ -297,7 +297,7 @@ public function commit()
/**
* @inheritDoc
*/
public function rollback()
public function rollback(): void
{
$this->getWrappedConnection()->rollback();
$this->getWrappedConnection()->autocommit(true);
Expand Down
6 changes: 3 additions & 3 deletions src/Model/Adapter/PDO/PDOAdapter.php
Expand Up @@ -204,23 +204,23 @@ private function runStmt(Statement $stmt)
/**
* @inheritDoc
*/
public function beginTransaction()
public function beginTransaction(): void
{
$this->getWrappedConnection()->beginTransaction();
}

/**
* @inheritDoc
*/
public function commit()
public function commit(): void
{
$this->getWrappedConnection()->commit();
}

/**
* @inheritDoc
*/
public function rollback()
public function rollback(): void
{
$this->getWrappedConnection()->rollBack();
}
Expand Down

0 comments on commit 2a366fa

Please sign in to comment.