Skip to content
Async Postgres client for PHP based on Amp.
PHP Shell
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples Update examples and readme Oct 15, 2018
src Remove unneeded str_replace() Feb 13, 2020
test Upgrade to PHP 7.1 Feb 6, 2020
travis Fix Transaction; Fix tests; Remove extension repo directories after i… Jul 1, 2018
.gitattributes Update export-ignore files Nov 23, 2017
.gitignore Ignore PHPUnit cache Feb 6, 2020
.php_cs Use common SQL interface library Jul 1, 2018
.travis.yml Update travis build Feb 13, 2020
LICENSE Update tests Sep 27, 2019
README.md Update readme Sep 30, 2019
composer.json Upgrade to PHP 7.1 Feb 6, 2020
phpdoc.dist.xml Initial commit Sep 14, 2016
phpunit.xml.dist Update tests Sep 27, 2019

README.md

postgres

Build Status Code Coverage Release License

Async PostgreSQL client built with Amp.

Installation

This package can be installed as a Composer dependency.

composer require amphp/postgres

Requirements

Note: pecl-ev is not compatible with ext-pgsql. If you wish to use pecl-ev for the event loop backend, you must use pecl-pq.

Documentation & Examples

Prepared statements and parameterized queries support named placeholders, as well as ? and standard numeric (i.e. $1) placeholders.

More examples can be found in the examples directory.

use Amp\Postgres;
use Amp\Postgres\ConnectionConfig;
use Amp\Sql\Statement;

Amp\Loop::run(function () {
    $config = ConnectionConfig::fromString("host=localhost user=postgres dbname=test");

    /** @var Postgres\Pool $pool */
    $pool = Postgres\pool($config);

    /** @var Statement $statement */
    $statement = yield $pool->prepare("SELECT * FROM test WHERE id = :id");

    /** @var Postgres\ResultSet $result */
    $result = yield $statement->execute(['id' => 1337]);
    while (yield $result->advance()) {
        $row = $result->getCurrent();
        // $row is an array (map) of column values. e.g.: $row['column_name']
    }
});

Versioning

amphp/postgres follows the semver semantic versioning specification like all other amphp packages.

Security

If you discover any security related issues, please email contact@amphp.org instead of using the issue tracker.

License

The MIT License (MIT). Please see LICENSE for more information.

You can’t perform that action at this time.