<HTML ><HEAD ><TITLE >pg_trace</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="PHP Manual" HREF="index.html"><LINK REL="UP" TITLE="PostgreSQL functions" HREF="ref.pgsql.html"><LINK REL="PREVIOUS" TITLE="pg_set_client_encoding" HREF="function.pg-set-client-encoding.html"><LINK REL="NEXT" TITLE="pg_tty" HREF="function.pg-tty.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-1"></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 Manual</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.pg-set-client-encoding.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.pg-tty.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.pg-trace" ></A >pg_trace</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN77977" ></A ><P > (PHP 4 >= 4.0.1)</P >pg_trace -- Enable tracing a PostgreSQL connection</DIV ><DIV CLASS="refsect1" ><A NAME="AEN77980" ></A ><H2 >Description</H2 >bool <B CLASS="methodname" >pg_trace</B > ( string pathname [, string mode [, resource connection]])<BR ></BR ><P > <B CLASS="function" >pg_trace()</B > enables tracing of the PostgreSQL frontend/backend communication to a debugging file specified as <TT CLASS="parameter" ><I >pathname</I ></TT >. To fully understand the results, one needs to be familiar with the internals of PostgreSQL communication protocol. For those who are not, it can still be useful for tracing errors in queries sent to the server, you could do for example <B CLASS="command" >grep '^To backend' trace.log</B > and see what query actually were sent to the PostgreSQL server. For more information, refer to PostgreSQL manual. </P ><P > <TT CLASS="parameter" ><I >pathname</I ></TT > and <TT CLASS="parameter" ><I >mode</I ></TT > are the same as in <A HREF="function.fopen.html" ><B CLASS="function" >fopen()</B ></A > (<TT CLASS="parameter" ><I >mode</I ></TT > defaults to 'w'), <TT CLASS="parameter" ><I >connection</I ></TT > specifies the connection to trace and defaults to the last one opened. </P ><P > It returns <TT CLASS="constant" ><B >TRUE</B ></TT > if <TT CLASS="parameter" ><I >pathname</I ></TT > could be opened for logging, <TT CLASS="constant" ><B >FALSE</B ></TT > otherwise. </P ><P > See also <A HREF="function.fopen.html" ><B CLASS="function" >fopen()</B ></A > and <A HREF="function.pg-untrace.html" ><B CLASS="function" >pg_untrace()</B ></A >. </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-set-client-encoding.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.pg-tty.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >pg_set_client_encoding</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.pgsql.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >pg_tty</TD ></TR ></TABLE ></DIV ></BODY ></HTML >