X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 83463D1B4D6 for ; Fri, 12 Dec 2003 14:20:14 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 30090-06 for ; Fri, 12 Dec 2003 10:19:46 -0400 (AST) Received: from rwcrmhc11.comcast.net (rwcrmhc11.comcast.net [204.127.198.35]) by svr1.postgresql.org (Postfix) with ESMTP id E6624D1B457 for ; Fri, 12 Dec 2003 10:19:41 -0400 (AST) Received: from hivemind.trini0.org (trini0.org[68.39.114.118]) by comcast.net (rwcrmhc11) with ESMTP id <2003121214193701300bo3n5e>; Fri, 12 Dec 2003 14:19:37 +0000 Received: from gladiator.trini0.org (gladiator.trini0.org [192.168.0.3]) by hivemind.trini0.org (Postfix) with ESMTP id DFBBA9E; Fri, 12 Dec 2003 09:19:36 -0500 (EST) From: Gerard Samuel To: Martin Marques , php-db@lists.php.net Subject: Re: [PHP-DB] pg_result_error() Date: Fri, 12 Dec 2003 09:19:36 -0500 User-Agent: KMail/1.5.4 References: <200312112209.54516.php-db@trini0.org> <200312120844.16882.martin@bugs.unl.edu.ar> In-Reply-To: <200312120844.16882.martin@bugs.unl.edu.ar> MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200312120908.18042.php-db@trini0.org> Cc: pgsql-php@postgresql.org Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200312/47 X-Sequence-Number: 2493 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=3D=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 --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. --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]