1
0
mirror of https://github.com/danog/postgres.git synced 2024-12-03 09:57:48 +01:00
Go to file
2020-06-05 09:48:15 -05:00
examples Update examples 2020-06-05 09:28:09 -05:00
src Use custom message with TimeoutCancellationToken 2020-06-05 09:48:15 -05:00
test Remove unused import 2020-05-22 18:39:03 -05:00
travis Fix Transaction; Fix tests; Remove extension repo directories after install on travis 2018-07-01 12:40:23 -05:00
.gitattributes Update export-ignore files 2017-11-22 20:35:23 -06:00
.gitignore Ignore PHPUnit cache 2020-02-06 17:55:27 -06:00
.php_cs Use common SQL interface library 2018-07-01 12:33:12 -05:00
.travis.yml Update travis build 2020-02-13 11:59:08 -06:00
composer.json Initial use of Stream API 2020-05-21 15:44:56 -05:00
LICENSE Update tests 2019-09-26 22:41:47 -05:00
phpdoc.dist.xml Initial commit 2016-09-14 09:27:39 -05:00
phpunit.xml.dist Update tests 2019-09-26 22:41:47 -05:00
README.md Update for Stream interface changes 2020-05-22 17:53:14 -05:00

postgres

Build Status Code Coverage Release License

Async PostgreSQL client for PHP 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\Result;
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 Result $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.