mirror of
https://github.com/danog/postgres.git
synced 2024-12-14 02:17:27 +01:00
48 lines
1.0 KiB
PHP
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(array $params = []): Promise {
|
|
return $this->statement->execute($params);
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function getQuery(): string {
|
|
return $this->statement->getQuery();
|
|
}
|
|
}
|