1
0
mirror of https://github.com/danog/postgres.git synced 2024-11-26 20:15:02 +01:00
Go to file
Aaron Piotrowski b3ff31ec0e
Rename TupleResult to ResultSet
Matches name in amphp/mysql.
2017-12-02 19:35:49 -06:00
examples Rename TupleResult to ResultSet 2017-12-02 19:35:49 -06:00
lib Rename TupleResult to ResultSet 2017-12-02 19:35:49 -06:00
test Rename TupleResult to ResultSet 2017-12-02 19:35:49 -06:00
travis Move extension installation to separate scripts 2017-05-26 16:33:11 -05:00
.gitattributes Update export-ignore files 2017-11-22 20:35:23 -06:00
.gitignore Use code fixer 2017-05-15 23:27:47 -05:00
.php_cs.dist Update and fix code styles 2017-06-20 22:59:42 -05:00
.travis.yml Test on 7.2 2017-11-22 20:35:11 -06:00
composer.json Use tagged versions 2017-06-18 00:14:46 -05:00
LICENSE Initial commit 2016-09-14 09:27:39 -05:00
Makefile Add Makefile 2017-06-20 23:04:23 -05:00
phpdoc.dist.xml Initial commit 2016-09-14 09:27:39 -05:00
phpunit.xml.dist Update to PHPUnit 6 2017-05-26 10:47:44 -05:00
README.md Link to pecl-pq (#4) 2017-11-06 13:36:00 +01:00

PostgreSQL Client for Amp

This library is a component for Amp that provides an asynchronous client for PostgreSQL.

Build Status Coverage Status Semantic Version MIT License @amphp on Twitter

Requirements
Installation

The recommended way to install is with the Composer package manager. (See the Composer installation guide for information on installing and using Composer.)

Run the following command to use this library in your project:

composer require amphp/postgres

You can also manually edit composer.json to add this library as a project requirement.

// composer.json
{
    "require": {
        "amphp/postgres": "^0.2"
    }
}

Example

#!/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\Statement $statement */
    $statement = yield $connection->prepare('SELECT * FROM test WHERE id=$1');

    /** @var \Amp\Postgres\TupleResult $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']
    }
});