Skip to content

Commit

Permalink
Merge ed6d570 into f50c02e
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveRandom committed Jul 9, 2018
2 parents f50c02e + ed6d570 commit e0e72d4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 24 deletions.
14 changes: 1 addition & 13 deletions src/Executor.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Amp\Promise;

interface Executor
interface Executor extends TransientResource
{
/**
* @param string $sql SQL query to execute.
Expand Down Expand Up @@ -40,18 +40,6 @@ public function prepare(string $sql): Promise;
*/
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.
*/
Expand Down
12 changes: 1 addition & 11 deletions src/Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Amp\Promise;

interface Statement
interface Statement extends TransientResource
{
/**
* @param mixed[] $params
Expand All @@ -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 changes: 20 additions & 0 deletions src/TransientResource.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php declare(strict_types=1);

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;
}

0 comments on commit e0e72d4

Please sign in to comment.