1
0
mirror of https://github.com/danog/postgres.git synced 2024-11-27 12:34:40 +01:00
postgres/lib/PgSqlStatement.php

41 lines
810 B
PHP
Raw Normal View History

2016-12-30 06:21:17 +01:00
<?php
2016-09-14 16:27:39 +02:00
namespace Amp\Postgres;
use Amp\Promise;
2016-09-14 16:27:39 +02:00
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 \Amp\Promise<\Amp\Postgres\Result>
2016-09-14 16:27:39 +02:00
*
* @throws \Amp\Postgres\FailureException If executing the statement fails.
*/
2016-11-15 18:06:21 +01:00
public function execute(...$params): Promise {
2016-09-14 16:27:39 +02:00
return ($this->execute)($this->sql, $params);
}
2017-05-16 06:28:37 +02:00
}