Swoole\Coroutine\PostgreSQL->connect(...)

4.x is outdated, please check the latest version 22.x


Latest version: pecl install openswoole-22.1.2

Declaration

<?php Swoole\Coroutine\PostgreSQL->connect(string $connectionString): bool

Parameters

connectionString

Pass in the Postgres connection string used to connect to the server and database.

Return

Returns true if there were no connection errors and false when there was a problem. Check the error message.


Description

Establish a postgresql non-blocking connection within a coroutine context.

The example shows you how to deal with connection errors.


Example

<?php

use Swoole\Coroutine\PostgreSQL;

Co\run(function()
{
    $pg = new PostgreSQL();
    $conn = $pg->connect("host=127.0.0.1;port=5432;dbname=test;user=postgres;password=***");
    var_dump($pg->error, $conn);
});
Last updated on August 31, 2022