OpenSwoole\Coroutine\PostgreSQL->status()

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

Declaration

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

Parameters

Return

Returns status of current PostgreSQL Client


Description

Get the status of current PostgreSQL client.

The emuns of PostgeSQL status:


\OpenSwoole\Constant::PG_CONNECTION_OK
\OpenSwoole\Constant::PG_CONNECTION_BAD
\OpenSwoole\Constant::PG_CONNECTION_STARTED
\OpenSwoole\Constant::PG_CONNECTION_AWAITING_RESPONSE
\OpenSwoole\Constant::PG_CONNECTION_AUTH_OK
\OpenSwoole\Constant::PG_CONNECTION_SETENV
\OpenSwoole\Constant::PG_CONNECTION_SSL_STARTUP
\OpenSwoole\Constant::PG_CONNECTION_NEEDED

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=***");

    $result = $pg->query('SELECT * FROM test;');
    $arr = $pg->fetchAll($result);
    var_dump($arr);
    var_dump($pg->status());
});
Last updated on September 20, 2022