1
0
mirror of https://github.com/danog/postgres.git synced 2025-01-22 13:21:14 +01:00
postgres/lib/PgSqlStatement.php
2016-11-15 11:06:21 -06:00

40 lines
856 B
PHP

<?php declare(strict_types = 1);
namespace Amp\Postgres;
use Interop\Async\Promise;
class PgSqlStatement implements Statement {
/** @var string */
private $sql;
/** @var callable */
private $execute;
/**
* @param string $sql
* @param callable $execute
*/
public function __construct(string $sql, callable $execute) {
$this->sql = $sql;
$this->execute = $execute;
}
/**
* @return string
*/
public function getQuery(): string {
return $this->sql;
}
/**
* @param mixed ...$params
*
* @return \Interop\Async\Promise<\Amp\Postgres\Result>
*
* @throws \Amp\Postgres\FailureException If executing the statement fails.
*/
public function execute(...$params): Promise {
return ($this->execute)($this->sql, $params);
}
}