OpenSwoole\Coroutine\PostgreSQL->status()

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

Declaration

<?php OpenSwoole\Coroutine\PostgreSQL->status(): int|false

Parameters

Return

Returns the connection status of the current PostgreSQL client, or false when the client is not connected.


Description

Get the connection status of current PostgreSQL client.

The connection status constants:

OPENSWOOLE_PG_CONNECTION_OK
OPENSWOOLE_PG_CONNECTION_BAD
OPENSWOOLE_PG_CONNECTION_STARTED
OPENSWOOLE_PG_CONNECTION_AWAITING_RESPONSE
OPENSWOOLE_PG_CONNECTION_AUTH_OK
OPENSWOOLE_PG_CONNECTION_SETENV
OPENSWOOLE_PG_CONNECTION_SSL_STARTUP
OPENSWOOLE_PG_CONNECTION_NEEDED

Example

<?php

use OpenSwoole\Coroutine\PostgreSQL;

co::run(function()
{
    $pg = new PostgreSQL();

    $pg->connect("host=127.0.0.1 port=5432 dbname=test user=postgres password=***");

    var_dump($pg->status() === OPENSWOOLE_PG_CONNECTION_OK);
});
Last updated on November 20, 2026