2016-12-30 06:21:17 +01:00
|
|
|
<?php
|
2016-09-14 16:27:39 +02:00
|
|
|
|
|
|
|
namespace Amp\Postgres;
|
|
|
|
|
2017-03-17 16:17:24 +01:00
|
|
|
use Amp\Promise;
|
2016-09-14 16:27:39 +02:00
|
|
|
|
|
|
|
interface Executor {
|
2017-07-28 06:20:16 +02:00
|
|
|
const STATEMENT_NAME_PREFIX = "amp_";
|
|
|
|
|
2016-09-14 16:27:39 +02:00
|
|
|
/**
|
|
|
|
* @param string $sql
|
|
|
|
*
|
2017-05-24 16:59:06 +02:00
|
|
|
* @return \Amp\Promise<\Amp\Postgres\CommandResult|\Amp\Postgres\TupleResult>
|
2016-09-14 16:27:39 +02:00
|
|
|
*
|
|
|
|
* @throws \Amp\Postgres\FailureException
|
|
|
|
*/
|
2016-11-15 18:06:21 +01:00
|
|
|
public function query(string $sql): Promise;
|
2016-09-14 16:27:39 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $sql
|
|
|
|
* @param mixed ...$params
|
|
|
|
*
|
2017-05-24 16:59:06 +02:00
|
|
|
* @return \Amp\Promise<\Amp\Postgres\CommandResult|\Amp\Postgres\TupleResult>
|
2016-09-14 16:27:39 +02:00
|
|
|
*
|
2017-05-26 20:14:04 +02:00
|
|
|
* @throws \Amp\Postgres\FailureException If the operation fails due to unexpected condition.
|
|
|
|
* @throws \Amp\Postgres\QueryError If the operation fails due to an error in the query (such as a syntax error).
|
|
|
|
* @throws \Amp\Postgres\PendingOperationError If another operation is currently pending on the connection.
|
2016-09-14 16:27:39 +02:00
|
|
|
*/
|
2016-11-15 18:06:21 +01:00
|
|
|
public function execute(string $sql, ...$params): Promise;
|
2016-09-14 16:27:39 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $sql
|
|
|
|
*
|
2017-03-17 16:17:24 +01:00
|
|
|
* @return \Amp\Promise<\Amp\Postgres\Statement>
|
2016-09-14 16:27:39 +02:00
|
|
|
*
|
2017-05-26 20:14:04 +02:00
|
|
|
* @throws \Amp\Postgres\FailureException If the operation fails due to unexpected condition.
|
|
|
|
* @throws \Amp\Postgres\QueryError If the operation fails due to an error in the query (such as a syntax error).
|
|
|
|
* @throws \Amp\Postgres\PendingOperationError If another operation is currently pending on the connection.
|
2016-09-14 16:27:39 +02:00
|
|
|
*/
|
2016-11-15 18:06:21 +01:00
|
|
|
public function prepare(string $sql): Promise;
|
2017-05-16 06:28:37 +02:00
|
|
|
|
2016-09-21 07:18:24 +02:00
|
|
|
/**
|
|
|
|
* @param string $channel Channel name.
|
|
|
|
* @param string $payload Notification payload.
|
|
|
|
*
|
2017-03-17 16:17:24 +01:00
|
|
|
* @return \Amp\Promise<\Amp\Postgres\CommandResult>
|
2017-05-26 20:14:04 +02:00
|
|
|
*
|
|
|
|
* @throws \Amp\Postgres\FailureException If the operation fails due to unexpected condition.
|
|
|
|
* @throws \Amp\Postgres\PendingOperationError If another operation is currently pending on the connection.
|
2016-09-21 07:18:24 +02:00
|
|
|
*/
|
2016-11-15 18:06:21 +01:00
|
|
|
public function notify(string $channel, string $payload = ""): Promise;
|
2016-09-14 16:27:39 +02:00
|
|
|
}
|