Skip to content

Commit 4fffbb2

Browse files
committed
Update readme
1 parent 13bd043 commit 4fffbb2

File tree

1 file changed

+24
-28
lines changed

1 file changed

+24
-28
lines changed

README.md

+24-28
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
<p align="center">
2-
<a href="https://amphp.org/postgres"><img src="https://raw.githubusercontent.com/amphp/logo/master/repos/postgres.png?v=12-07-2017" alt="postgres"/></a>
3-
</p>
1+
# amphp/postgres
42

5-
<p align="center">
6-
<a href="https://travis-ci.org/amphp/postgres"><img src="https://img.shields.io/travis/amphp/postgres/master.svg?style=flat-square" alt="Build Status"/></a>
7-
<a href="https://coveralls.io/github/amphp/postgres?branch=master"><img src="https://img.shields.io/coveralls/amphp/postgres/master.svg?style=flat-square" alt="Code Coverage"/></a>
8-
<a href="https://github.com/amphp/postgres/releases"><img src="https://img.shields.io/github/release/amphp/postgres.svg?style=flat-square" alt="Release"/></a>
9-
<a href="https://github.com/amphp/postgres/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square" alt="License"/></a>
10-
</p>
3+
AMPHP is a collection of event-driven libraries for PHP designed with fibers and concurrency in mind.
4+
`amphp/postgres` is an asynchronous Postgres client.
5+
The library implements concurrent querying by transparently distributing queries across a scalable pool of available connections. Either [ext-pgsql](https://secure.php.net/pgsql) (bundled with PHP) or [pecl-pq](https://pecl.php.net/package/pq) are required.
116

12-
<p align="center"><strong>Async PostgreSQL client for PHP built with <a href="https://amphp.org/">Amp</a>.</strong></p>
7+
## Features
8+
9+
- Exposes a non-blocking API for issuing multiple Postgres queries concurrently
10+
- Transparent connection pooling to overcome Postgres' fundamentally synchronous connection protocol
11+
- Support for parameterized prepared statements
12+
- Nested transactions with commit and rollback event hooks
13+
- Unbuffered results to reduce memory usage for large result sets
14+
- Support for sending and receiving notifications
1315

1416
## Installation
1517

@@ -21,7 +23,7 @@ composer require amphp/postgres
2123

2224
## Requirements
2325

24-
- PHP 7.1+
26+
- PHP 8.1+
2527
- [ext-pgsql](https://secure.php.net/pgsql) or [pecl-pq](https://pecl.php.net/package/pq)
2628

2729
Note: [pecl-ev](https://pecl.php.net/package/ev) is not compatible with ext-pgsql. If you wish to use pecl-ev for the event loop backend, you must use pecl-pq.
@@ -30,30 +32,24 @@ Note: [pecl-ev](https://pecl.php.net/package/ev) is not compatible with ext-pgsq
3032

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

35+
Row values are cast to their corresponding PHP types. For example, integer columns will be an `int` in the result row array.
36+
3337
More examples can be found in the [`examples`](examples) directory.
3438

3539
```php
36-
use Amp\Postgres;
3740
use Amp\Postgres\PostgresConfig;
38-
use Amp\Sql\Result;
39-
use Amp\Sql\Statement;
41+
use Amp\Postgres\PostgresConnectionPool;
4042

41-
Amp\Loop::run(function () {
42-
$config = PostgresConfig::fromString("host=localhost user=postgres db=test");
43+
$config = PostgresConfig::fromString("host=localhost user=postgres db=test");
4344

44-
/** @var Postgres\Pool $pool */
45-
$pool = Postgres\pool($config);
45+
$pool = new PostgresConnectionPool($config);
4646

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

50-
/** @var Result $result */
51-
$result = yield $statement->execute(['id' => 1337]);
52-
while (yield $result->advance()) {
53-
$row = $result->getCurrent();
54-
// $row is an array (map) of column values. e.g.: $row['column_name']
55-
}
56-
});
49+
$result = $statement->execute(['id' => 1337]);
50+
foreach ($result as $row) {
51+
// $row is an associative-array of column values, e.g.: $row['column_name']
52+
}
5753
```
5854

5955
## Versioning
@@ -62,7 +58,7 @@ Amp\Loop::run(function () {
6258

6359
## Security
6460

65-
If you discover any security related issues, please email [`[email protected]`](mailto:[email protected]) instead of using the issue tracker.
61+
If you discover any security related issues, please use the private security issue reporter instead of using the public issue tracker.
6662

6763
## License
6864

0 commit comments

Comments
 (0)