AMPHP PostgreSQL¶
The AMPHP PostgreSQL driver, amphp/postgres, is an asynchronous
PostgreSQL client based on Amp.
Install
composer require amphp/postgres
Synopsis
<?php
require 'vendor/autoload.php';
use Amp\Postgres\PostgresConfig;
use Amp\Postgres\PostgresConnectionPool;
use function Amp\async;
use function Amp\Future\await;
await(async(function () {
$config = PostgresConfig::fromString("host=localhost user=crate");
$pool = new PostgresConnectionPool($config);
$statement = $pool->prepare("SELECT * FROM sys.summits ORDER BY height DESC LIMIT 3");
$result = $statement->execute();
foreach ($result as $row) {
print_r($row);
}
}));
?>
See also
Documentation
The full documentation for amphp/postgres.
Example
An executable example using the amphp/postgres driver.