pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Re: [PHP-DB] pg_result_error()
3+ messages / 2 participants
[nested] [flat]

* Re: [PHP-DB] pg_result_error()
@ 2003-12-12 14:19  Gerard Samuel <php-db@trini0.org>
  0 siblings, 1 reply; 3+ messages in thread

From: Gerard Samuel @ 2003-12-12 14:19 UTC (permalink / raw)
  To: Martin Marques <martin@bugs.unl.edu.ar>; php-db@lists.php.net; +Cc: pgsql-php

Im going to CC this to the PostgreSQL list also.

On Friday 12 December 2003 06:44 am, Martin Marques wrote:
> El Vie 12 Dic 2003 00:09, Gerard Samuel escribió:
> > What good is this function?
> > A quick example of the wall Im running into ->
> > $sql = 'INSERT INTO .....';
> > $result = pg_query($conn_id, $sql);
> > if ($result === false)
> > {
> >     var_dump( pg_result_error( $result ) );
>
> I would use here this:
> 	die(pg_result_error( $result ));

That is fine and all, but my original example was just an example of the non 
functionality of pg_result_error(), not how to handle errors when a query 
fails.
But for arguement sake, lets use your example in some dummy code[0].
$result is still boolean false, and pg_result_error() will still return an 
empty string, and using die, would just die, with no report of what happened.
Then whats the use of pg_result_error().

> > According to the manual, pg_result_error takes the result resource.
> > If that resource is boolean false for one reason or another, then
> > pg_result_error isn't useful.
> > Anyone has any other ideas, besides using
> > pg_last_error()?
>
> Did you try it?

Yes I've tried it.  In my DB class, Im currently using both pg_result_error() 
and pg_last_error(), with pg_last_error() being secondary (a fall back) to 
pg_result_error().
Because according to the manual ->
http://us2.php.net/manual/en/function.pg-last-error.php
--quote--
Error messages may be overwritten by internal PostgreSQL(libpq) function 
calls. It may not return appropriate error message, if multiple errors are 
occured inside a PostgreSQL module function.

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

So again, I beg the question.
What good is pg_result_error(), when you *must* feed it boolean false and it 
returns an empty string??

[0]
<?php

$conn = pg_connect("dbname=foo user=bar password=pass");

$sql = 'SELECT * FROM flagss';  // flags was misspelled
$result = @pg_query($conn, $sql);  // returns false
if ($result === false)
{
    die( pg_result_error($result) );  // results in an empty page????
}

?>




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: [PHP-DB] pg_result_error()
@ 2003-12-12 15:24  Martin Marques <martin@bugs.unl.edu.ar>
  parent: Gerard Samuel <php-db@trini0.org>
  0 siblings, 1 reply; 3+ messages in thread

From: Martin Marques @ 2003-12-12 15:24 UTC (permalink / raw)
  To: Gerard Samuel <php-db@trini0.org>; php-db@lists.php.net; +Cc: pgsql-php

El Vie 12 Dic 2003 11:19, Gerard Samuel escribió:
> Im going to CC this to the PostgreSQL list also.
>
> On Friday 12 December 2003 06:44 am, Martin Marques wrote:
> > El Vie 12 Dic 2003 00:09, Gerard Samuel escribió:
> > > What good is this function?
> > > A quick example of the wall Im running into ->
> > > $sql = 'INSERT INTO .....';
> > > $result = pg_query($conn_id, $sql);
> > > if ($result === false)
> > > {
> > >     var_dump( pg_result_error( $result ) );
> >
> > I would use here this:
> > 	die(pg_result_error( $result ));
>
> That is fine and all, but my original example was just an example of the
> non functionality of pg_result_error(), not how to handle errors when a
> query fails.
> But for arguement sake, lets use your example in some dummy code[0].
> $result is still boolean false, and pg_result_error() will still return an
> empty string, and using die, would just die, with no report of what
> happened. Then whats the use of pg_result_error().

Looks like you are totally right. Tried it and it works horrible. Any idea on 
why this is like this?

P.D.: I had to pass my php4 in Debian to unstable to get a workable (with the 
newer capabilities) version. Very annoing, especially becuase I had to pass 
apache to unstable as well. :-(

--
 12:13:01 up 16 days, 18:29,  3 users,  load average: 1.32, 0.90, 0.67
-----------------------------------------------------------------
Martín Marqués        | select 'mmarques' || '@' || 'unl.edu.ar'
Centro de Telematica  |  DBA, Programador, Administrador
             Universidad Nacional
                  del Litoral
-----------------------------------------------------------------




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: [PHP-DB] pg_result_error()
@ 2003-12-12 21:51  Gerard Samuel <php-db@trini0.org>
  parent: Martin Marques <martin@bugs.unl.edu.ar>
  0 siblings, 0 replies; 3+ messages in thread

From: Gerard Samuel @ 2003-12-12 21:51 UTC (permalink / raw)
  To: Martin Marques <martin@bugs.unl.edu.ar>; php-db@lists.php.net; +Cc: pgsql-php

On Friday 12 December 2003 10:24 am, Martin Marques wrote:
> > That is fine and all, but my original example was just an example of the
> > non functionality of pg_result_error(), not how to handle errors when a
> > query fails.
> > But for arguement sake, lets use your example in some dummy code[0].
> > $result is still boolean false, and pg_result_error() will still return
> > an empty string, and using die, would just die, with no report of what
> > happened. Then whats the use of pg_result_error().
>
> Looks like you are totally right. Tried it and it works horrible. Any idea
> on why this is like this?
>

Seems like Im not the only one who thought this function is useless...
http://bugs.php.net/bug.php?id=18747
So Im going to modify my code to not use this function, as it is really a 
total waste of time at the moment.
Thanks for the chat...




^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2003-12-12 21:51 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-12-12 14:19 Re: [PHP-DB] pg_result_error() Gerard Samuel <php-db@trini0.org>
2003-12-12 15:24 ` Martin Marques <martin@bugs.unl.edu.ar>
2003-12-12 21:51   ` Gerard Samuel <php-db@trini0.org>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox