amphp / postgres
Asynchronous PostgreSQL client for Amp.
Fund package maintenance!
amphp
Installs: 158 377
Dependents: 15
Suggesters: 1
Security: 0
Stars: 76
Watchers: 12
Forks: 18
Open Issues: 1
Requires
- php: >=8.1
- amphp/amp: ^3
- amphp/pipeline: ^1
- amphp/sql: ^2
- amphp/sql-common: ^2
Requires (Dev)
- ext-pgsql: *
- ext-pq: *
- amphp/php-cs-fixer-config: ^2-dev
- amphp/phpunit-util: ^3
- phpunit/phpunit: ^9
- psalm/phar: ^5.4
This package is auto-updated.
Last update: 2023-05-07 15:16:35 UTC
README
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\PostgresConfig; use Amp\Sql\Result; use Amp\Sql\Statement; Amp\Loop::run(function () { $config = PostgresConfig::fromString("host=localhost user=postgres db=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.