PHP Velho Oeste 2024

pg_set_error_context_visibility

(PHP 8 >= 8.3.0)

pg_set_error_context_visibility pg_last_error() が返すコンテクストのエラーメッセージのアクセス権を設定する

説明

pg_set_error_context_visibility(PgSql\Connection $connection, int $visibility): int

pg_last_error()pg_result_error() が返す、コンテクストのエラーメッセージのアクセス権を設定します

パラメータ

connection

PgSql\Connection クラスのインスタンス。

visibility

必要なアクセス権を指定します: PGSQL_SHOW_CONTEXT_NEVER, PGSQL_SHOW_CONTEXT_ERRORS, PGSQL_SHOW_CONTEXT_ALWAYS

戻り値

直前のアクセス権レベルを返します: PGSQL_SHOW_CONTEXT_NEVER, PGSQL_SHOW_CONTEXT_ERRORS, PGSQL_SHOW_CONTEXT_ALWAYS

例1 pg_set_error_context_visibility() の例

<?php
$dbconn
= pg_connect("dbname=publisher") or die("Could not connect");

if (!
pg_connection_busy($dbconn)) {
pg_send_query($dbconn, "select * from doesnotexist;");
}

pg_set_error_context_visibility($dbconn, PGSQL_SHOW_CONTEXT_ALWAYS);
$res1 = pg_get_result($dbconn);
echo
pg_result_error($res1);
?>

参考

  • pg_last_error() - 特定の接続から直近のエラーメッセージ文字列を取得する
  • pg_result_error() - 結果に関連するエラーメッセージを取得する

add a note add a note

User Contributed Notes

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