Join 4,000+ others and never miss out on new tips, tutorials, and more.
Latest version:
pecl install openswoole-22.1.2 | composer require openswoole/core:22.1.5
<?php OpenSwoole\Coroutine\PostgreSQL->connect(string $connectionString): bool
Pass in the Postgres connection string used to connect to the server and database.
Returns true
if there were no connection errors and false
when there was a problem. Check the error message.
Establish a postgresql
non-blocking connection within a coroutine context.
The example shows you how to deal with connection errors.
<?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);
});