1
0
mirror of https://github.com/danog/postgres.git synced 2024-11-26 20:15:02 +01:00

Update readme

This commit is contained in:
Aaron Piotrowski 2017-12-08 20:43:05 -06:00
parent 02265884d3
commit 2d9e97aabc
No known key found for this signature in database
GPG Key ID: ADD1EF783EDE9EEB

View File

@ -1,62 +1,58 @@
# PostgreSQL Client for Amp
<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>
This library is a component for [Amp](https://github.com/amphp/amp) that provides an asynchronous client for PostgreSQL.
<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>
[![Build Status](https://img.shields.io/travis/amphp/postgres/master.svg?style=flat-square)](https://travis-ci.org/amphp/postgres)
[![Coverage Status](https://img.shields.io/coveralls/amphp/postgres/master.svg?style=flat-square)](https://coveralls.io/r/amphp/postgres)
[![Semantic Version](https://img.shields.io/github/release/amphp/postgres.svg?style=flat-square)](http://semver.org)
[![MIT License](https://img.shields.io/packagist/l/amphp/postgres.svg?style=flat-square)](LICENSE)
[![@amphp on Twitter](https://img.shields.io/badge/twitter-%40asyncphp-5189c7.svg?style=flat-square)](https://twitter.com/asyncphp)
<p align="center"><strong>Async PostgreSQL client built with <a href="https://amphp.org/">Amp</a>.</strong></p>
##### Requirements
## Installation
- PHP 7+
- [ext-pgsql](https://secure.php.net/pgsql) or [pecl-pq](https://pecl.php.net/package/pq)
##### Installation
The recommended way to install is with the [Composer](http://getcomposer.org/) package manager. (See the [Composer installation guide](https://getcomposer.org/doc/00-intro.md) for information on installing and using Composer.)
Run the following command to use this library in your project:
This package can be installed as a [Composer](https://getcomposer.org/) dependency.
```bash
composer require amphp/postgres
```
You can also manually edit `composer.json` to add this library as a project requirement.
## Requirements
```json
// composer.json
{
"require": {
"amphp/postgres": "^0.2"
}
}
```
- PHP 7.0+
- [ext-pgsql](https://secure.php.net/pgsql) or [pecl-pq](https://pecl.php.net/package/pq)
#### Example
## Documentation & Examples
More examples can be found in the [`examples`](examples) directory.
```php
#!/usr/bin/env php
<?php
require __DIR__ . '/vendor/autoload.php';
use Amp\Postgres;
Amp\Loop::run(function () {
/** @var \Amp\Postgres\Connection $connection */
$connection = yield Postgres\connect('host=localhost user=postgres dbname=test');
/** @var \Amp\Postgres\Pool $pool */
$pool = Amp\Postgres\pool("host=localhost user=postgres dbname=test");
/** @var \Amp\Postgres\Statement $statement */
$statement = yield $connection->prepare('SELECT * FROM test WHERE id=$1');
/** @var \Amp\Postgres\TupleResult $result */
$result = yield $statement->execute(1337);
$statement = yield $pool->prepare("SELECT * FROM test WHERE id=$1");
/** @var \Amp\Postgres\ResultSet $result */
$result = yield $statement->execute([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](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.