Skip to content

Commit

Permalink
Move beginTransaction back to Link and extend Link in Transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
trowski committed Nov 23, 2023
1 parent 3154922 commit c2f0e27
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
9 changes: 8 additions & 1 deletion src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* @template TConfig of SqlConfig
* @template TResult of Result
* @template TStatement of Statement
* @template TStatement of Statement<TResult>
* @template TTransaction of Transaction
*
* @extends Link<TResult, TStatement, TTransaction>
Expand All @@ -16,4 +16,11 @@ interface Connection extends Link
* @return TConfig The configuration used to create this connection.
*/
public function getConfig(): SqlConfig;

/**
* Sets the transaction isolation level for transactions began on this link.
*
* @see Link::beginTransaction()
*/
public function setTransactionIsolation(TransactionIsolation $isolation): void;
}
8 changes: 0 additions & 8 deletions src/Executor.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
/**
* @template TResult of Result
* @template TStatement of Statement
* @template TTransaction of Transaction
*/
interface Executor extends TransientResource
{
Expand Down Expand Up @@ -42,11 +41,4 @@ public function prepare(string $sql): Statement;
* @throws QueryError If the operation fails due to an error in the query (such as a syntax error).
*/
public function execute(string $sql, array $params = []): Result;

/**
* Starts a transaction, returning an object where all queries are executed on a single connection.
*
* @return TTransaction
*/
public function beginTransaction(): Transaction;
}
10 changes: 5 additions & 5 deletions src/Link.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@

/**
* @template TResult of Result
* @template TStatement of Statement
* @template TStatement of Statement<TResult>
* @template TTransaction of Transaction
*
* @extends Executor<TResult, TStatement, TTransaction>
* @extends Executor<TResult, TStatement>
*/
interface Link extends Executor
{
/**
* Sets the transaction isolation level for transactions began on this link.
* Starts a transaction, returning an object where all queries are executed on a single connection.
*
* @see Executor::beginTransaction()
* @return TTransaction
*/
public function setTransactionIsolation(TransactionIsolation $isolation): void;
public function beginTransaction(): Transaction;
}
5 changes: 3 additions & 2 deletions src/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
* @template TResult of Result
* @template TStatement of Statement<TResult>
* @template TTransaction of Transaction
* @extends Executor<TResult, TStatement, TTransaction>
*
* @extends Link<TResult, TStatement, TTransaction>
*/
interface Transaction extends Executor
interface Transaction extends Link
{
public function getIsolationLevel(): TransactionIsolation;

Expand Down

0 comments on commit c2f0e27

Please sign in to comment.