3 namespace pq\Query\Executor
;
5 use \pq\Query\Executor
;
6 use \pq\Query\WriterInterface
;
9 * @requires \React\Promise
11 use \React\Promise\Deferred
;
14 * An asynchronous query executor
16 class Async
extends Executor
19 * Execute the query asynchronously through \pq\Connection::execParamsAsync()
20 * @param \pq\Query\WriterInterface $query
21 * @param callable $callback
22 * @return \React\Promise\DeferredPromise
24 function execute(WriterInterface
$query, callable
$callback) {
26 $this->query
= $query;
29 $deferred = new Deferred
;
30 $this->getConnection()->execParamsAsync($query, $query->getParams(), $query->getTypes(),
31 array($deferred->resolver(), "resolve"));
33 return $deferred->then(function($result) {
34 $this->result
= $result;