OpenSwoole\Coroutine\PostgreSQLStatement->fieldCount()

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

Declaration

<?php OpenSwoole\Coroutine\PostgreSQLStatement->fieldCount(): int|false

Parameters

Return

Returns the number of fields, or false when the statement has no result.


Description

Returns the number of fields (columns) in the result of the statement.


Example

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

    $stmt = $pg->query("SELECT id, text FROM test");
    var_dump($stmt->fieldCount());
});
Last updated on November 20, 2026