Skip to content

Commit 6306f4f

Browse files
committed
Update examples
1 parent 9b51bbe commit 6306f4f

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

examples/basic.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@
66
use Amp\Postgres;
77

88
Amp\Loop::run(function () {
9+
$host = 'localhost';
10+
$port = Postgres\ConnectionConfig::DEFAULT_PORT;
11+
$user = 'postgres';
12+
913
/** @var \Amp\Postgres\Connection $connection */
10-
$connection = yield Postgres\connect(new Postgres\ConnectionConfig('host=localhost user=postgres'));
14+
$connection = yield Postgres\connect(new Postgres\ConnectionConfig($host, $port, $user));
1115

1216
/** @var \Amp\Postgres\ResultSet $result */
1317
$result = yield $connection->query('SHOW ALL');

examples/listen.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
use Amp\Postgres;
88

99
Loop::run(function () {
10-
$pool = Postgres\pool(new Postgres\ConnectionConfig('host=localhost user=postgres'));
10+
$host = 'localhost';
11+
$port = Postgres\ConnectionConfig::DEFAULT_PORT;
12+
$user = 'postgres';
13+
14+
$pool = Postgres\pool(new Postgres\ConnectionConfig($host, $port, $user));
1115

1216
$channel = "test";
1317

examples/multi-listen.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
use Amp\Postgres;
99

1010
Loop::run(function () {
11-
$pool = Postgres\pool(new Postgres\ConnectionConfig('host=localhost user=postgres'));
11+
$host = 'localhost';
12+
$port = Postgres\ConnectionConfig::DEFAULT_PORT;
13+
$user = 'postgres';
14+
15+
$pool = Postgres\pool(new Postgres\ConnectionConfig($host, $port, $user));
1216

1317
$channel1 = "test1";
1418
$channel2 = "test2";

examples/transaction.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@
66
use Amp\Postgres;
77

88
Amp\Loop::run(function () {
9-
$pool = Postgres\pool(new Postgres\ConnectionConfig('host=localhost user=postgres'));
9+
$host = 'localhost';
10+
$port = Postgres\ConnectionConfig::DEFAULT_PORT;
11+
$user = 'postgres';
12+
13+
$pool = Postgres\pool(new Postgres\ConnectionConfig($host, $port, $user));
1014

1115
yield $pool->query('DROP TABLE IF EXISTS test');
1216

1317
/** @var \Amp\Postgres\Transaction $transaction */
14-
$transaction = yield $pool->transaction();
18+
$transaction = yield $pool->beginTransaction();
1519

1620
yield $transaction->query('CREATE TABLE test (domain VARCHAR(63), tld VARCHAR(63), PRIMARY KEY (domain, tld))');
1721

0 commit comments

Comments
 (0)