<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >pg_parameter_status</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK REL="HOME" TITLE="PHP 手册" HREF="index.html"><LINK REL="UP" TITLE="PostgreSQL 数据库函数" HREF="ref.pgsql.html"><LINK REL="PREVIOUS" TITLE="pg_options" HREF="function.pg-options.html"><LINK REL="NEXT" TITLE="pg_pconnect" HREF="function.pg-pconnect.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8"></HEAD ><BODY CLASS="refentry" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PHP 手册</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.pg-options.html" ACCESSKEY="P" >上一页</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.pg-pconnect.html" ACCESSKEY="N" >下一页</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.pg-parameter-status" ></A >pg_parameter_status</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN186287" ></A ><P > (PHP 5)</P >pg_parameter_status -- Looks up a current parameter setting of the server.</DIV ><DIV CLASS="refsect1" ><A NAME="AEN186290" ></A ><H2 >说明</H2 >string <B CLASS="methodname" >pg_parameter_status</B > ( resource connection, string param_name )<BR ></BR >string <B CLASS="methodname" >pg_parameter_status</B > ( string param_name )<BR ></BR ><P > Looks up a current parameter setting of the server. </P ><P > Certain parameter values are reported by the server automatically at connection startup or whenever their values change. <B CLASS="function" >pg_parameter_status()</B > can be used to interrogate these settings. It returns the current value of a parameter if known, or <TT CLASS="constant" ><B >FALSE</B ></TT > if the parameter is not known. </P ><P > Parameters reported as of PostgreSQL 8.0 include <TT CLASS="literal" >server_version</TT >, <TT CLASS="literal" >server_encoding</TT >, <TT CLASS="literal" >client_encoding</TT >, <TT CLASS="literal" >is_superuser</TT >, <TT CLASS="literal" >session_authorization</TT >, <TT CLASS="literal" >DateStyle</TT >, <TT CLASS="literal" >TimeZone</TT >, and <TT CLASS="literal" >integer_datetimes</TT >. (<TT CLASS="literal" >server_encoding</TT >, <TT CLASS="literal" >TimeZone</TT >, and <TT CLASS="literal" >integer_datetimes</TT > were not reported by releases before 8.0.) Note that <TT CLASS="literal" >server_version</TT >, <TT CLASS="literal" >server_encoding</TT > and <TT CLASS="literal" >integer_datetimes</TT > cannot change after PostgreSQL startup. </P ><P > PostgreSQL 7.3 or lower servers do not report parameter settings, <B CLASS="function" >pg_parameter_status()</B > includes logic to obtain values for <TT CLASS="literal" >server_version</TT > and <TT CLASS="literal" >client_encoding</TT > anyway. Applications are encouraged to use <B CLASS="function" >pg_parameter_status()</B > rather than ad hoc code to determine these values. </P ><DIV CLASS="caution" ><P ></P ><TABLE CLASS="caution" BORDER="1" WIDTH="100%" ><TR ><TD ALIGN="CENTER" ><B >小心</B ></TD ></TR ><TR ><TD ALIGN="LEFT" ><P > On a pre-7.4 PostgreSQL server, changing <TT CLASS="literal" >client_encoding</TT > via <TT CLASS="literal" >SET</TT > after connection startup will not be reflected by <B CLASS="function" >pg_parameter_status()</B >. </P ></TD ></TR ></TABLE ></DIV ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN186336" ></A ><H2 >参数</H2 ><P > <P ></P ><DIV CLASS="variablelist" ><DL ><DT ><CODE CLASS="parameter" >connection</CODE ></DT ><DD ><P > PostgreSQL database connection resource. When <CODE CLASS="parameter" >connection</CODE > is not present, the default connection is used. The default connection is the last connection made by <A HREF="function.pg-connect.html" ><B CLASS="function" >pg_connect()</B ></A > or <A HREF="function.pg-pconnect.html" ><B CLASS="function" >pg_pconnect()</B ></A >. </P ></DD ><DT ><CODE CLASS="parameter" >param_name</CODE ></DT ><DD ><P > Possible <CODE CLASS="parameter" >param_name</CODE > values include <TT CLASS="literal" >server_version</TT >, <TT CLASS="literal" >server_encoding</TT >, <TT CLASS="literal" >client_encoding</TT >, <TT CLASS="literal" >is_superuser</TT >, <TT CLASS="literal" >session_authorization</TT >, <TT CLASS="literal" >DateStyle</TT >, <TT CLASS="literal" >TimeZone</TT >, and <TT CLASS="literal" >integer_datetimes</TT >. </P ></DD ></DL ></DIV > </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN186362" ></A ><H2 >返回值</H2 ><P >A <A HREF="language.types.string.html" ><B CLASS="type" >string</B ></A > containing the value of the parameter, <TT CLASS="constant" ><B >FALSE</B ></TT > on failure or invalid <CODE CLASS="parameter" >param_name</CODE >.</P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN186368" ></A ><H2 >范例</H2 ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN186371" ></A ><P ><B >例 1. <B CLASS="function" >pg_parameter_status()</B > example</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><code><font color="#000000"> <font color="#0000BB"><?php<br /> $dbconn </font><font color="#007700">= </font><font color="#0000BB">pg_connect</font><font color="#007700">(</font><font color="#DD0000">"dbname=publisher"</font><font color="#007700">) or die(</font><font color="#DD0000">"Could not connect"</font><font color="#007700">);<br /><br /> echo </font><font color="#DD0000">"Server encoding: "</font><font color="#007700">, </font><font color="#0000BB">pg_parameter_status</font><font color="#007700">(</font><font color="#0000BB">$dbconn</font><font color="#007700">, </font><font color="#DD0000">"server_encoding"</font><font color="#007700">);<br /></font><font color="#0000BB">?></font> </font> </code></TD ></TR ></TABLE ><P >上例将输出:</P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="screen" >Server encoding: SQL_ASCII</PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.pg-options.html" ACCESSKEY="P" >上一页</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >起始页</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.pg-pconnect.html" ACCESSKEY="N" >下一页</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >pg_options</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.pgsql.html" ACCESSKEY="U" >上一级</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >pg_pconnect</TD ></TR ></TABLE ></DIV ></BODY ></HTML >