-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
222 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Amp\Mysql\Internal; | ||
|
||
use Amp\Mysql\MysqlResult; | ||
use Amp\Mysql\MysqlStatement; | ||
use Amp\Mysql\MysqlTransaction; | ||
use Amp\Sql\Common\NestedTransaction; | ||
|
||
/** | ||
* @internal | ||
* @extends NestedTransaction<MysqlResult, MysqlStatement, MysqlTransaction> | ||
*/ | ||
class MysqlNestedTransaction extends NestedTransaction implements MysqlTransaction | ||
{ | ||
use MysqlTransactionDelegate; | ||
|
||
protected function getTransaction(): MysqlTransaction | ||
{ | ||
return $this->transaction; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Amp\Mysql\Internal; | ||
|
||
use Amp\Mysql\MysqlResult; | ||
use Amp\Mysql\MysqlStatement; | ||
use Amp\Mysql\MysqlTransaction; | ||
use Amp\Sql\Result; | ||
use Amp\Sql\Statement; | ||
|
||
/** @internal */ | ||
trait MysqlTransactionDelegate | ||
{ | ||
abstract protected function getTransaction(): MysqlTransaction; | ||
|
||
protected function createStatement(Statement $statement, \Closure $release): MysqlStatement | ||
{ | ||
\assert($statement instanceof MysqlStatement); | ||
return new MysqlPooledStatement($statement, $release); | ||
} | ||
|
||
protected function createResult(Result $result, \Closure $release): MysqlResult | ||
{ | ||
\assert($result instanceof MysqlResult); | ||
return new MysqlPooledResult($result, $release); | ||
} | ||
|
||
/** | ||
* Changes return type to this library's Result type. | ||
*/ | ||
public function query(string $sql): MysqlResult | ||
{ | ||
return parent::query($sql); | ||
} | ||
|
||
/** | ||
* Changes return type to this library's Statement type. | ||
*/ | ||
public function prepare(string $sql): MysqlStatement | ||
{ | ||
return parent::prepare($sql); | ||
} | ||
|
||
/** | ||
* Changes return type to this library's Result type. | ||
*/ | ||
public function execute(string $sql, array $params = []): MysqlResult | ||
{ | ||
return parent::execute($sql, $params); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Amp\Mysql; | ||
|
||
use Amp\Sql\Common\NestableTransaction; | ||
use Amp\Sql\Transaction; | ||
use Amp\Sql\TransactionIsolation; | ||
use Amp\Sql\TransactionIsolationLevel; | ||
|
||
/** | ||
* @extends NestableTransaction<MysqlResult, MysqlStatement, MysqlTransaction> | ||
*/ | ||
class MysqlNestableTransaction extends NestableTransaction implements MysqlLink | ||
{ | ||
protected function createNestedTransaction( | ||
Transaction $transaction, | ||
\Closure $release, | ||
string $identifier, | ||
): Transaction { | ||
return new Internal\MysqlNestedTransaction($transaction, $release, $identifier); | ||
} | ||
|
||
/** | ||
* Changes return type to this library's Transaction type. | ||
*/ | ||
public function beginTransaction( | ||
TransactionIsolation $isolation = TransactionIsolationLevel::Committed | ||
): MysqlTransaction { | ||
return parent::beginTransaction($isolation); | ||
} | ||
|
||
/** | ||
* Changes return type to this library's Result type. | ||
*/ | ||
public function query(string $sql): MysqlResult | ||
{ | ||
return parent::query($sql); | ||
} | ||
|
||
/** | ||
* Changes return type to this library's Statement type. | ||
*/ | ||
public function prepare(string $sql): MysqlStatement | ||
{ | ||
return parent::prepare($sql); | ||
} | ||
|
||
/** | ||
* Changes return type to this library's Result type. | ||
*/ | ||
public function execute(string $sql, array $params = []): MysqlResult | ||
{ | ||
return parent::execute($sql, $params); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.