1
0
mirror of https://github.com/danog/postgres.git synced 2024-12-04 10:18:17 +01:00
postgres/examples/1-basic.php
Aaron Piotrowski e742c25c3e
Update examples
2020-06-05 09:28:09 -05:00

23 lines
583 B
PHP

#!/usr/bin/env php
<?php
require \dirname(__DIR__) . '/vendor/autoload.php';
use Amp\Postgres;
use Amp\Postgres\Connection;
use Amp\Sql\Result;
Amp\Loop::run(function () {
$config = Postgres\ConnectionConfig::fromString('host=localhost user=postgres');
/** @var Connection $connection */
$connection = yield Postgres\connect($config);
/** @var Result $result */
$result = yield $connection->query('SHOW ALL');
while ($row = yield $result->continue()) {
\printf("%-35s = %s (%s)\n", $row['name'], $row['setting'], $row['description']);
}
});