2018-06-26 13:14:24 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Amp\Sql;
|
|
|
|
|
|
|
|
use Amp\Promise;
|
|
|
|
|
2018-07-09 09:55:12 +02:00
|
|
|
interface Executor extends TransientResource
|
2018-06-29 12:15:39 +02:00
|
|
|
{
|
2018-06-26 13:14:24 +02:00
|
|
|
/**
|
|
|
|
* @param string $sql SQL query to execute.
|
|
|
|
*
|
2018-06-28 23:16:18 +02:00
|
|
|
* @return Promise<CommandResult|ResultSet>
|
2018-06-26 13:14:24 +02:00
|
|
|
*
|
2018-06-28 23:16:18 +02:00
|
|
|
* @throws FailureException If the operation fails due to unexpected condition.
|
|
|
|
* @throws ConnectionException If the connection to the database is lost.
|
|
|
|
* @throws QueryError If the operation fails due to an error in the query (such as a syntax error).
|
2018-06-26 13:14:24 +02:00
|
|
|
*/
|
|
|
|
public function query(string $sql): Promise;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $sql SQL query to prepare.
|
|
|
|
*
|
2018-06-28 23:16:18 +02:00
|
|
|
* @return Promise<Statement>
|
2018-06-26 13:14:24 +02:00
|
|
|
*
|
2018-06-28 23:16:18 +02:00
|
|
|
* @throws FailureException If the operation fails due to unexpected condition.
|
|
|
|
* @throws ConnectionException If the connection to the database is lost.
|
|
|
|
* @throws QueryError If the operation fails due to an error in the query (such as a syntax error).
|
2018-06-26 13:14:24 +02:00
|
|
|
*/
|
|
|
|
public function prepare(string $sql): Promise;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $sql SQL query to prepare and execute.
|
|
|
|
* @param mixed[] $params Query parameters.
|
|
|
|
*
|
2018-06-28 23:16:18 +02:00
|
|
|
* @return Promise<CommandResult|ResultSet>
|
2018-06-26 13:14:24 +02:00
|
|
|
*
|
2018-06-28 23:16:18 +02:00
|
|
|
* @throws FailureException If the operation fails due to unexpected condition.
|
|
|
|
* @throws ConnectionException If the connection to the database is lost.
|
|
|
|
* @throws QueryError If the operation fails due to an error in the query (such as a syntax error).
|
2018-06-26 13:14:24 +02:00
|
|
|
*/
|
|
|
|
public function execute(string $sql, array $params = []): Promise;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Closes the executor. No further queries may be performed.
|
|
|
|
*/
|
|
|
|
public function close();
|
|
|
|
}
|