1
0
mirror of https://github.com/danog/postgres.git synced 2024-12-15 19:07:26 +01:00
postgres/lib/Internal/PooledStatement.php
2017-11-05 18:18:01 -06:00

48 lines
1.0 KiB
PHP

<?php
namespace Amp\Postgres\Internal;
use Amp\Postgres\Connection;
use Amp\Postgres\Statement;
use Amp\Promise;
class PooledStatement implements Statement {
/** @var \Amp\Postgres\Connection */
private $connection;
/** @var \Amp\Postgres\Statement */
private $statement;
/** @var callable */
private $push;
/**
* @param \Amp\Postgres\Connection $connection
* @param \Amp\Postgres\Statement $statement
* @param callable $push
*/
public function __construct(Connection $connection, Statement $statement, callable $push) {
$this->connection = $connection;
$this->statement = $statement;
$this->push = $push;
}
public function __destruct() {
($this->push)($this->connection);
}
/**
* {@inheritdoc}
*/
public function execute(...$params): Promise {
return $this->statement->execute(...$params);
}
/**
* {@inheritdoc}
*/
public function getQuery(): string {
return $this->statement->getQuery();
}
}