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

24 lines
655 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-14 17:48:07 +02:00
$host = 'localhost';
$port = Postgres\ConnectionConfig::DEFAULT_PORT;
$user = 'postgres';
2017-05-26 21:41:02 +02:00
/** @var \Amp\Postgres\Connection $connection */
2018-10-14 17:48:07 +02:00
$connection = yield Postgres\connect(new Postgres\ConnectionConfig($host, $port, $user));
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']);
}
});