amphp / postgres
Asynchronous PostgreSQL client for Amp.
Fund package maintenance!
amphp
Installs: 286 709
Dependents: 22
Suggesters: 1
Security: 0
Stars: 97
Watchers: 12
Forks: 20
Open Issues: 3
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
- amphp/phpunit-util: ^3
- phpunit/phpunit: ^9
- psalm/phar: 5.23
- 2.x-dev
- v2.1.1
- v2.1.0
- v2.0.0
- v2.0.0-beta.6
- v2.0.0-beta.5
- v2.0.0-beta.4
- v2.0.0-beta.3
- v2.0.0-beta.2
- v2.0.0-beta.1
- 1.x-dev
- v1.4.5
- v1.4.4
- v1.4.3
- v1.4.2
- v1.4.1
- v1.4.0
- v1.3.3
- v1.3.2
- v1.3.1
- v1.3.0
- v1.2.1
- v1.2.0
- v1.1.1
- v1.1.0
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- v0.2.1
- v0.2.0
- v0.1.2
- v0.1.1
- v0.1.0
- dev-array-parser
This package is auto-updated.
Last update: 2024-11-22 23:36:20 UTC
README
AMPHP is a collection of event-driven libraries for PHP designed with fibers and concurrency in mind.
amphp/postgres
is an asynchronous Postgres client.
The library implements concurrent querying by transparently distributing queries across a scalable pool of available connections. Either ext-pgsql (bundled with PHP) or pecl-pq are required.
Features
- Exposes a non-blocking API for issuing multiple Postgres queries concurrently
- Transparent connection pooling to overcome Postgres' fundamentally synchronous connection protocol
- Support for parameterized prepared statements
- Nested transactions with commit and rollback event hooks
- Unbuffered results to reduce memory usage for large result sets
- Support for sending and receiving notifications
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.
Row values are cast to their corresponding PHP types. For example, integer columns will be an int
in the result row array.
More examples can be found in the examples
directory.
use Amp\Postgres\PostgresConfig; use Amp\Postgres\PostgresConnectionPool; $config = PostgresConfig::fromString("host=localhost user=postgres db=test"); $pool = new PostgresConnectionPool($config); $statement = $pool->prepare("SELECT * FROM test WHERE id = :id"); $result = $statement->execute(['id' => 1337]); foreach ($result as $row) { // $row is an associative-array 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 use the private security issue reporter instead of using the public issue tracker.
License
The MIT License (MIT). Please see LICENSE
for more information.