OpenSwoole\Coroutine\PostgreSQL->escapeIdentifier(...)

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

Declaration

<?php OpenSwoole\Coroutine\PostgreSQL->escapeIdentifier(string $string): string|false

Parameters

string

The identifier (table, column or other name) to escape.

Return

Returns the escaped identifier including the surrounding double quotes, or false on failure, check the error property.


Description

Escape a string for use as a SQL identifier such as a table or column name, using PQescapeIdentifier(). The returned value includes the double quotes.

The client must be connected.


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

    $table = $pg->escapeIdentifier('user data');
    var_dump($table); // string(11) ""user data""

    $stmt = $pg->query("SELECT * FROM {$table}");
    var_dump($stmt->fetchAll());
});
Last updated on November 20, 2026