1
0
mirror of https://github.com/danog/postgres.git synced 2024-11-30 04:29:12 +01:00
postgres/lib/Executor.php
Aaron Piotrowski e0a842bad7 Disallow multiple operations on single connection
Pools can still be used for concurrent ops.
2017-05-26 13:14:04 -05:00

51 lines
1.8 KiB
PHP

<?php
namespace Amp\Postgres;
use Amp\Promise;
interface Executor {
/**
* @param string $sql
*
* @return \Amp\Promise<\Amp\Postgres\CommandResult|\Amp\Postgres\TupleResult>
*
* @throws \Amp\Postgres\FailureException
*/
public function query(string $sql): Promise;
/**
* @param string $sql
* @param mixed ...$params
*
* @return \Amp\Promise<\Amp\Postgres\CommandResult|\Amp\Postgres\TupleResult>
*
* @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.
*/
public function execute(string $sql, ...$params): Promise;
/**
* @param string $sql
*
* @return \Amp\Promise<\Amp\Postgres\Statement>
*
* @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.
*/
public function prepare(string $sql): Promise;
/**
* @param string $channel Channel name.
* @param string $payload Notification payload.
*
* @return \Amp\Promise<\Amp\Postgres\CommandResult>
*
* @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.
*/
public function notify(string $channel, string $payload = ""): Promise;
}