Skip to content

Commit

Permalink
Update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
trowski committed Oct 14, 2018
1 parent 9b51bbe commit 6306f4f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
6 changes: 5 additions & 1 deletion examples/basic.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
use Amp\Postgres;

Amp\Loop::run(function () {
$host = 'localhost';
$port = Postgres\ConnectionConfig::DEFAULT_PORT;
$user = 'postgres';

/** @var \Amp\Postgres\Connection $connection */
$connection = yield Postgres\connect(new Postgres\ConnectionConfig('host=localhost user=postgres'));
$connection = yield Postgres\connect(new Postgres\ConnectionConfig($host, $port, $user));

/** @var \Amp\Postgres\ResultSet $result */
$result = yield $connection->query('SHOW ALL');
Expand Down
6 changes: 5 additions & 1 deletion examples/listen.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
use Amp\Postgres;

Loop::run(function () {
$pool = Postgres\pool(new Postgres\ConnectionConfig('host=localhost user=postgres'));
$host = 'localhost';
$port = Postgres\ConnectionConfig::DEFAULT_PORT;
$user = 'postgres';

$pool = Postgres\pool(new Postgres\ConnectionConfig($host, $port, $user));

$channel = "test";

Expand Down
6 changes: 5 additions & 1 deletion examples/multi-listen.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
use Amp\Postgres;

Loop::run(function () {
$pool = Postgres\pool(new Postgres\ConnectionConfig('host=localhost user=postgres'));
$host = 'localhost';
$port = Postgres\ConnectionConfig::DEFAULT_PORT;
$user = 'postgres';

$pool = Postgres\pool(new Postgres\ConnectionConfig($host, $port, $user));

$channel1 = "test1";
$channel2 = "test2";
Expand Down
8 changes: 6 additions & 2 deletions examples/transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@
use Amp\Postgres;

Amp\Loop::run(function () {
$pool = Postgres\pool(new Postgres\ConnectionConfig('host=localhost user=postgres'));
$host = 'localhost';
$port = Postgres\ConnectionConfig::DEFAULT_PORT;
$user = 'postgres';

$pool = Postgres\pool(new Postgres\ConnectionConfig($host, $port, $user));

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

/** @var \Amp\Postgres\Transaction $transaction */
$transaction = yield $pool->transaction();
$transaction = yield $pool->beginTransaction();

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

Expand Down

0 comments on commit 6306f4f

Please sign in to comment.