Join 4,000+ others and never miss out on new tips, tutorials, and more.
Latest version:
pecl install openswoole-26.11.1 | composer require openswoole/core:26.11.1
<?php OpenSwoole\Coroutine\PostgreSQL->status(): int|false
Returns the connection status of the current PostgreSQL client, or false when the client is not connected.
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
<?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);
});