Re: pg_result_error()

Re: pg_result_error()

am 12.12.2003 15:19:36 von Gerard Samuel

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=F3:
> > What good is this function?
> > A quick example of the wall Im running into ->
> > $sql =3D 'INSERT INTO .....';
> > $result =3D pg_query($conn_id, $sql);
> > if ($result ===3D 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 no=
n=20
functionality of pg_result_error(), not how to handle errors when a query=20
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=
=20
empty string, and using die, would just die, with no report of what happene=
d.
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=
()=20
and pg_last_error(), with pg_last_error() being secondary (a fall back) to=
=20
pg_result_error().
Because according to the manual ->
http://us2.php.net/manual/en/function.pg-last-error.php
=2D-quote--
Error messages may be overwritten by internal PostgreSQL(libpq) function=20
calls. It may not return appropriate error message, if multiple errors are=
=20
occured inside a PostgreSQL module function.

Use pg_result_error(), pg_result_status() and pg_connection_status() for=20
better error handling.
=2D-quote--

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

[0]

$conn =3D pg_connect("dbname=3Dfoo user=3Dbar password=3Dpass");

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

?>

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: pg_result_error()

am 12.12.2003 16:24:57 von Martin Marques

El Vie 12 Dic 2003 11:19, Gerard Samuel escribi=F3:
> 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=F3:
> > > What good is this function?
> > > A quick example of the wall Im running into ->
> > > $sql =3D 'INSERT INTO .....';
> > > $result =3D pg_query($conn_id, $sql);
> > > if ($result ===3D 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=20
why this is like this?

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

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

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: pg_result_error()

am 12.12.2003 16:24:57 von Martin Marques

El Vie 12 Dic 2003 11:19, Gerard Samuel escribi=F3:
> 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=F3:
> > > What good is this function?
> > > A quick example of the wall Im running into ->
> > > $sql =3D 'INSERT INTO .....';
> > > $result =3D pg_query($conn_id, $sql);
> > > if ($result ===3D 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=20
why this is like this?

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

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

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] [PHP-DB] pg_result_error()

am 12.12.2003 22:51:49 von Gerard Samuel

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...

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] [PHP-DB] pg_result_error()

am 12.12.2003 22:51:49 von Gerard Samuel

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...

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php