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->fetchArray(resource $queryResult, int $row, $resultType = SW_PGSQL_BOTH): array|false
The result of a executed SQL query which will be a PHP resource variable type.
The number of the row you want to extract as an array.
How you want the array to be returned, check types below.
Returns a single row as an array based on the row number and result type.
Extract a single row as an array.
The row count starts from 0. Returns false
when there is no more rows to extract or you get to the end.
Return Types
<?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->fetchArray($result, 1, OpenSwoole\Coroutine\PostgreSQL::PGSQL_ASSOC);
var_dump($arr);
});