PG_TRACE(3)PG_TRACE(3)pg_trace - Enable tracing a PostgreSQL connectionSYNOPSIS
bool pg_trace (string $pathname, [string $mode = "w"], [resource $connection])
DESCRIPTION pg_trace(3) enables tracing of the PostgreSQL frontend/backend communication to a file. 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 grep '^To backend'
trace.log and see what queries actually were sent to the PostgreSQL server. For more information, refer to the PostgreSQL Documentation.
PARAMETERS
o $pathname
- The full path and file name of the file in which to write the trace log. Same as in fopen(3).
o $mode
- An optional file access mode, same as for fopen(3).
o $connection
- PostgreSQL database connection resource. When $connection is not present, the default connection is used. The default connection
is the last connection made by pg_connect(3) or pg_pconnect(3).
RETURN VALUES
Returns TRUE on success or FALSE on failure.
EXAMPLES
Example #1
pg_trace(3) example
<?php
$pgsql_conn = pg_connect("dbname=mark host=localhost");
if ($pgsql_conn) {
pg_trace('/tmp/trace.log', 'w', $pgsql_conn);
pg_query("SELECT 1");
pg_untrace($pgsql_conn);
// Now /tmp/trace.log will contain backend communication
} else {
print pg_last_error($pgsql_conn);
exit;
}
?>
SEE ALSO fopen(3), pg_untrace(3).
PHP Documentation Group PG_TRACE(3)
Check Out this Related Man Page
PG_LAST_ERROR(3)PG_LAST_ERROR(3)pg_last_error - Get the last error message string of a connectionSYNOPSIS
string pg_last_error ([resource $connection])
DESCRIPTION pg_last_error(3) returns the last error message for a given $connection.
Error messages may be overwritten by internal PostgreSQL (libpq) function calls. It may not return an appropriate error message if multi-
ple errors occur inside a PostgreSQL module function.
Use pg_result_error(3), pg_result_error_field(3), pg_result_status(3) and pg_connection_status(3) for better error handling.
Note
This function used to be called pg_errormessage(3).
PARAMETERS
o $connection
- PostgreSQL database connection resource. When $connection is not present, the default connection is used. The default connection
is the last connection made by pg_connect(3) or pg_pconnect(3).
RETURN VALUES
A string containing the last error message on the given $connection, or FALSE on error.
EXAMPLES
Example #1
pg_last_error(3) example
<?php
$dbconn = pg_connect("dbname=publisher") or die("Could not connect");
// Query that fails
$res = pg_query($dbconn, "select * from doesnotexist");
echo pg_last_error($dbconn);
?>
SEE ALSO pg_result_error(3), pg_result_error_field(3).
PHP Documentation Group PG_LAST_ERROR(3)
Hi,
look at the following code:
The client after estabilishing a connection with the server does the following:
if ((peter = fopen(argv, "r")) == NULL){
printf("errore\n");
exit(0);
}
... (11 Replies)
Hello,
first of all, I want to make myself clear about my language. I'm brazilian, so I ask you all to understand if i commit any mistake with the grammar.
Here is the problem.
Some days ago I needed to use a "sh" command in the Terminal (I use a Mac OSX 10.5.6) followed by a file... (0 Replies)
Hi All,
Although this code is quite long but it does not require one to understand the logic of the code. I am trying to run this code on my Linux machine using gcc. But when this line is executed:
output_pointer = fopen ( file_name , "w" );I get segmentation fault. I've been breaking my head... (17 Replies)