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

Latest version: pecl install openswoole-22.1.2 | composer require openswoole/core:22.1.5

Declaration

<?php OpenSwoole\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 OpenSwoole\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 September 1, 2022