PHP Conference Ehime 2026

pg_service

(PHP 8 >= 8.5.0)

pg_serviceGets the service name of the connection

説明

function pg_service(?PgSql\Connection $connection = null): string

Returns the name of the connection service used to establish the connection, as defined in the connection service file.

This function is only available if PHP has been built against libpq 18 or later.

パラメータ

connection

PgSql\Connection クラスのインスタンス。 connectionnull, の場合、デフォルトの接続を使います。 デフォルトの接続とは、pg_connect() または pg_pconnect() によって確立された直近の接続です。

警告

PHP 8.1.0 以降では、デフォルトの接続を使うことは推奨されなくなりました。

戻り値

A string containing the service name of the connection, or an empty string if no service was used.

参考

  • pg_connect() - PostgreSQL 接続をオープンする
  • pg_dbname() - データベース名を取得する
  • pg_host() - 接続に関連するホスト名を返す
  • pg_port() - 接続に関連するポート番号を返す
add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top