Join 4,000+ others and never miss out on new tips, tutorials, and more.
4.x is outdated, please check the latest version 25.x
Latest version:
pecl install openswoole-25.2.0
<?php Swoole\Coroutine\PostgreSQL->status(): int
Returns status of current PostgreSQL Client
Get the status of current PostgreSQL client.
The emuns of PostgeSQL status:
\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 Swoole\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());
});