amphp/postgres
Composer 安装命令:
composer require amphp/postgres
包简介
Asynchronous PostgreSQL client for Amp.
README 文档
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.
amphp/postgres 适用场景与选型建议
amphp/postgres 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 579.02k 次下载、GitHub Stars 达 108, 最近一次更新时间为 2017 年 06 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「database」 「db」 「postgresql」 「pgsql」 「async」 「asynchronous」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 amphp/postgres 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 amphp/postgres 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 amphp/postgres 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
SilverStripe now has tentative support for PostgreSQL ('Postgres')
Dibi is Database Abstraction Library for PHP
Async Reactive Postgres Driver for PHP (Non-blocking)
Store your language lines in the database, yaml or other sources
Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.
A package for automatically encrypting and decrypting Eloquent attributes in Laravel 5.5+, based on configuration settings.
统计信息
- 总下载量: 579.02k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 110
- 点击次数: 18
- 依赖项目数: 32
- 推荐数: 3
其他信息
- 授权协议: MIT
- 更新时间: 2017-06-21