2017-12-09 03:43:05 +01:00
|
|
|
<p align="center">
|
|
|
|
<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>
|
|
|
|
</p>
|
2016-09-14 16:27:39 +02:00
|
|
|
|
2017-12-09 03:43:05 +01:00
|
|
|
<p align="center">
|
|
|
|
<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>
|
|
|
|
<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>
|
|
|
|
<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>
|
|
|
|
<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>
|
|
|
|
</p>
|
2016-09-14 16:27:39 +02:00
|
|
|
|
2017-12-09 03:43:05 +01:00
|
|
|
<p align="center"><strong>Async PostgreSQL client built with <a href="https://amphp.org/">Amp</a>.</strong></p>
|
2016-09-14 16:27:39 +02:00
|
|
|
|
2017-12-09 03:43:05 +01:00
|
|
|
## Installation
|
2016-09-14 16:27:39 +02:00
|
|
|
|
2017-12-09 03:43:05 +01:00
|
|
|
This package can be installed as a [Composer](https://getcomposer.org/) dependency.
|
2016-09-14 16:27:39 +02:00
|
|
|
|
|
|
|
```bash
|
|
|
|
composer require amphp/postgres
|
|
|
|
```
|
|
|
|
|
2017-12-09 03:43:05 +01:00
|
|
|
## Requirements
|
2016-09-14 16:27:39 +02:00
|
|
|
|
2017-12-09 03:43:05 +01:00
|
|
|
- PHP 7.0+
|
|
|
|
- [ext-pgsql](https://secure.php.net/pgsql) or [pecl-pq](https://pecl.php.net/package/pq)
|
2016-09-14 16:27:39 +02:00
|
|
|
|
2017-12-09 03:43:05 +01:00
|
|
|
## Documentation & Examples
|
2016-09-14 16:27:39 +02:00
|
|
|
|
2017-12-09 03:43:05 +01:00
|
|
|
More examples can be found in the [`examples`](examples) directory.
|
2016-09-14 16:27:39 +02:00
|
|
|
|
2017-12-09 03:43:05 +01:00
|
|
|
```php
|
2017-05-24 16:59:16 +02:00
|
|
|
Amp\Loop::run(function () {
|
2017-12-09 03:43:05 +01:00
|
|
|
/** @var \Amp\Postgres\Pool $pool */
|
|
|
|
$pool = Amp\Postgres\pool("host=localhost user=postgres dbname=test");
|
2016-09-14 16:27:39 +02:00
|
|
|
|
|
|
|
/** @var \Amp\Postgres\Statement $statement */
|
2017-12-09 03:43:05 +01:00
|
|
|
$statement = yield $pool->prepare("SELECT * FROM test WHERE id=$1");
|
2016-09-14 16:27:39 +02:00
|
|
|
|
2017-12-09 03:43:05 +01:00
|
|
|
/** @var \Amp\Postgres\ResultSet $result */
|
|
|
|
$result = yield $statement->execute([1337]);
|
2017-05-24 16:59:16 +02:00
|
|
|
while (yield $result->advance()) {
|
2016-09-14 16:27:39 +02:00
|
|
|
$row = $result->getCurrent();
|
|
|
|
// $row is an array (map) of column values. e.g.: $row['column_name']
|
|
|
|
}
|
|
|
|
});
|
2017-11-06 13:36:00 +01:00
|
|
|
```
|
2017-12-09 03:43:05 +01:00
|
|
|
|
|
|
|
## Versioning
|
|
|
|
|
|
|
|
`amphp/postgres` follows the [semver](http://semver.org/) semantic versioning specification like all other `amphp` packages.
|
|
|
|
|
|
|
|
## Security
|
|
|
|
|
|
|
|
If you discover any security related issues, please email [`contact@amphp.org`](mailto:contact@amphp.org) instead of using the issue tracker.
|
|
|
|
|
|
|
|
## License
|
|
|
|
|
|
|
|
The MIT License (MIT). Please see [`LICENSE`](./LICENSE) for more information.
|