php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #18747 pg_result_error is complete useless
Submitted: 2002-08-05 17:58 UTC Modified: 2004-07-27 20:50 UTC
Votes:7
Avg. Score:4.6 ± 0.7
Reproduced:7 of 7 (100.0%)
Same Version:4 (57.1%)
Same OS:4 (57.1%)
From: vincent at sunlight dot tmfweb dot nl Assigned: yohgaki
Status: Closed Package: Documentation problem
PHP Version: 4.2.2 OS: Linux
Private report: No CVE-ID:
 [2002-08-05 17:58 UTC] vincent at sunlight dot tmfweb dot nl
The function pg_result_error() supposedly gives the error 
message for some failed SQL query after calling pg_query() 
with that query. It must be given a resource identifier of 
the result to get the error message for that result 
(sounds alright). 
 
However, function pg_query() returns FALSE if a query 
failed instead of a result identifier, so what can 
possibly be passed to pq_result_error() in this case? The 
query certainly went wrong, but there's no way to check 
exactly what, as there is no resource identifier... 
 
Almost looks like a Catch 22. 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-08-07 03:12 UTC] yohgaki@php.net
Looks like I need to explain how it could be useful.
If you cannot wait, read libpq manual.


 [2003-06-22 20:19 UTC] jc at mega-bucks dot co dot jp
When will the documentation be updated? This bug report has been open for 10 months now ...

The documentation clearly states that we should be using this function instead of the *old* pg_last_error():

http://jp.php.net/manual/en/function.pg-last-error.php

Use pg_result_error(), pg_result_status() and pg_connection_status() for better error handling.

But as the first person who reported this bug noted, the current implementation of this function is useless. You can't pass it a valid ressource identifier because pg_query() returns false on failure.

Having a valid bug report open for almost one year is a bit too long ....

I really want to use this function as it seems very useful and more robust than pg_last_error() but I can't figure out at all how to use it ...
 [2003-12-13 10:39 UTC] aspire420 at hotpop dot com
I also tried this function with no good result. I suppose this 
function must be made workable as PostgreSQL 7.4 > have error codes rather than strings and with those error codes we have to throw some realistic and meaning full output to our applications
 [2004-07-27 20:50 UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

"Because pg_query() returns false if the query fails, you must must use pg_send_query() and pg_get_result() to get the result handle."

Thanks to anonymous user contributed note for explaining.
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Mon Apr 21 12:02:07 2014 UTC