Extract TransientResource interface
This commit is contained in:
parent
130bcb5c10
commit
15c2090945
@ -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.
|
||||
*/
|
||||
|
@ -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;
|
||||
}
|
||||
|
20
src/TransientResource.php
Normal file
20
src/TransientResource.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Amp\Sql;
|
||||
|
||||
interface TransientResource
|
||||
{
|
||||
/**
|
||||
* Indicates if the resource is still valid.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isAlive(): bool;
|
||||
|
||||
/**
|
||||
* Get the timestamp of the last usage of this resource.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function lastUsedAt(): int;
|
||||
}
|
Loading…
Reference in New Issue
Block a user