PHP code example of amphp / postgres

1. Go to this page and download the library: Download amphp/postgres library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

amphp / postgres example snippets


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']
}