1
0
mirror of https://github.com/danog/postgres.git synced 2024-11-26 20:15:02 +01:00
postgres/examples/basic.php
2018-07-01 12:33:12 -05:00

20 lines
563 B
PHP

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