1
0
mirror of https://github.com/danog/postgres.git synced 2024-12-11 08:59:42 +01:00
postgres/examples/basic.php

22 lines
595 B
PHP
Raw Normal View History

2016-09-14 16:27:39 +02:00
#!/usr/bin/env php
<?php
2018-07-01 19:33:12 +02:00
require \dirname(__DIR__) . '/vendor/autoload.php';
2016-09-14 16:27:39 +02:00
use Amp\Postgres;
Amp\Loop::run(function () {
2018-10-15 17:44:40 +02:00
$config = Postgres\ConnectionConfig::fromString('host=localhost user=postgres');
2018-10-14 17:48:07 +02:00
2017-05-26 21:41:02 +02:00
/** @var \Amp\Postgres\Connection $connection */
2018-10-15 17:44:40 +02:00
$connection = yield Postgres\connect($config);
2017-05-16 06:28:37 +02:00
/** @var \Amp\Postgres\ResultSet $result */
2017-05-26 21:41:02 +02:00
$result = yield $connection->query('SHOW ALL');
2017-05-16 06:28:37 +02:00
2017-01-18 19:52:40 +01:00
while (yield $result->advance()) {
2016-09-14 16:27:39 +02:00
$row = $result->getCurrent();
\printf("%-35s = %s (%s)\n", $row['name'], $row['setting'], $row['description']);
}
});