From 15c209094591cdc5b29f08d403a917e464d463c0 Mon Sep 17 00:00:00 2001 From: Chris Wright Date: Mon, 9 Jul 2018 08:55:12 +0100 Subject: [PATCH] Extract TransientResource interface --- src/Executor.php | 14 +------------- src/Statement.php | 12 +----------- src/TransientResource.php | 20 ++++++++++++++++++++ 3 files changed, 22 insertions(+), 24 deletions(-) create mode 100644 src/TransientResource.php diff --git a/src/Executor.php b/src/Executor.php index 9607bca..8b8eaae 100644 --- a/src/Executor.php +++ b/src/Executor.php @@ -4,7 +4,7 @@ namespace Amp\Sql; use Amp\Promise; -interface Executor +interface Executor extends TransientResource { /** * @param string $sql SQL query to execute. @@ -40,18 +40,6 @@ interface Executor */ public function execute(string $sql, array $params = []): Promise; - /** - * Indicates if the connection to the database is still alive. - * - * @return bool - */ - public function isAlive(): bool; - - /** - * @return int Timestamp of the last time this connection was used. - */ - public function lastUsedAt(): int; - /** * Closes the executor. No further queries may be performed. */ diff --git a/src/Statement.php b/src/Statement.php index fc1c8fc..b29a795 100644 --- a/src/Statement.php +++ b/src/Statement.php @@ -4,7 +4,7 @@ namespace Amp\Sql; use Amp\Promise; -interface Statement +interface Statement extends TransientResource { /** * @param mixed[] $params @@ -13,18 +13,8 @@ interface Statement */ public function execute(array $params = []): Promise; - /** - * @return bool True if the statement can still be executed, false if the connection has died. - */ - public function isAlive(): bool; - /** * @return string The SQL string used to prepare the statement. */ public function getQuery(): string; - - /** - * @return int Timestamp of when the statement was last used. - */ - public function lastUsedAt(): int; } diff --git a/src/TransientResource.php b/src/TransientResource.php new file mode 100644 index 0000000..20f55bc --- /dev/null +++ b/src/TransientResource.php @@ -0,0 +1,20 @@ +