array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'function.pg-set-error-context-visibility.php', 1 => 'pg_set_error_context_visibility', 2 => 'Determines the visibility of the context\'s error messages returned by pg_last_error and pg_result_error', ), 'up' => array ( 0 => 'ref.pgsql.php', 1 => 'PostgreSQL 函数', ), 'prev' => array ( 0 => 'function.pg-set-client-encoding.php', 1 => 'pg_set_client_encoding', ), 'next' => array ( 0 => 'function.pg-set-error-verbosity.php', 1 => 'pg_set_error_verbosity', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/pgsql/functions/pg-set-error-context-visibility.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>
(PHP 8 >= 8.3.0)
pg_set_error_context_visibility — Determines the visibility of the context's error messages returned by pg_last_error() and pg_result_error()
Determines the visibility of the context's error messages returned by pg_last_error() and pg_result_error()
connection
PgSql\Connection 实例。
visibility
The required visibility: PGSQL_SHOW_CONTEXT_NEVER
,
PGSQL_SHOW_CONTEXT_ERRORS
or PGSQL_SHOW_CONTEXT_ALWAYS
.
The previous visibility level: PGSQL_SHOW_CONTEXT_NEVER
,
PGSQL_SHOW_CONTEXT_ERRORS
or PGSQL_SHOW_CONTEXT_ALWAYS
.
示例 #1 pg_set_error_context_visibility() example
<?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);
?>