Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 4BC6E633672 for ; Tue, 22 Sep 2009 10:17:55 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 56721-08 for ; Tue, 22 Sep 2009 13:17:36 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-qy0-f204.google.com (mail-qy0-f204.google.com [209.85.221.204]) by mail.postgresql.org (Postfix) with ESMTP id 3755B632EB0 for ; Tue, 22 Sep 2009 10:17:44 -0300 (ADT) Received: by qyk42 with SMTP id 42so2951017qyk.28 for ; Tue, 22 Sep 2009 06:17:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:cc:content-type; bh=0ZhbylgEVAH9jCAUOIZqfZhd2TxtX5AFuvTn7FcDifA=; b=lhO7k7vdMPwxTMkhk7ujK3BRRF2OJFwZ7ZRSlZXVAiSR2MniCl/qvALbpVAlZJk0T+ EWDDvHKwGZuTpsZTtzXrbQ3UqfC7uS2xO540fHA64fbKHr5Dnpvfya56qQAJopmFKaYe pIknJDQ/WgRscuynVs7CXn5QwJUBnso/hS7AA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; b=AqspUNtGZ1yQ27ULucIXQMY44l+w1wcoT53/pcID6L6fBiDX7rfsPpB5eh3X538A/s q23yRqdUhxEldmaKH99LgvL49+5XASRbBMptkheMh4hCRgKyInFE4VWjhyQ64b1R32A5 nVmdkejYyX36xm/BDT3nO9DGqrifGRHS385NU= MIME-Version: 1.0 Received: by 10.224.48.4 with SMTP id p4mr624957qaf.231.1253625461149; Tue, 22 Sep 2009 06:17:41 -0700 (PDT) In-Reply-To: <4AB821BD.6070508@gmail.com> References: <4AB821BD.6070508@gmail.com> From: Gustavo Amarilla Santacruz Date: Tue, 22 Sep 2009 09:17:21 -0400 Message-ID: Subject: Re: Error code To: Chris Cc: pgsql-php@postgresql.org Content-Type: multipart/alternative; boundary=000fea892bfb4b8e7404742a6ce1 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.714 tagged_above=-10 required=5 tests=BAYES_00=-2.599, HTML_FONT_FACE_BAD=0.884, HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 200909/17 X-Sequence-Number: 4075 --000fea892bfb4b8e7404742a6ce1 Content-Type: text/plain; charset=ISO-8859-1 Thank you, Chris. Now, I need to do this in PHP: -------------------- CODE --------------------------------------------------------------- $errorCode = pg_result_error_field($res1, PGSQL_DIAG_SQLSTATE) ; if( $errorCode == UNIQUE_VIOLATION ) echo( "message 1" ); else if( $errorCode == DATETIME_FIELD_OVERFLOW ) echo( "message 2" ); -------------------- CODE --------------------------------------------------------------- How I can do it?; how I can compare $errorCode with a Postgres error name ( as in http://www.postgresql.org/docs/8.1/static/errcodes-appendix.html ). Thank you, again. On Mon, Sep 21, 2009 at 9:00 PM, Chris wrote: > Gustavo Amarilla Santacruz wrote: > >> Hello all. >> >> How I can get the postgres error code from PHP?. I can get the error text, >> but I need error code to verbose ( and country dependient) messages. >> > > http://www.php.net/manual/en/function.pg-result-error-field.php > > seems to be the best fit. > > -- > Postgresql & php tutorials > http://www.designmagick.com/ > > -- Gustavo Amarilla --000fea892bfb4b8e7404742a6ce1 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Thank you, Chris.

Now, I need to do this in PHP:

-------------------- CODE -------------------------------= --------------------------------

$errorCode =3D=A0= pg_result_error_field($res1, PGSQL_DIAG_SQLSTATE) ;

if( $errorCode =3D=3D UNIQUE_VIOLATION )<= /div>
= =A0=A0 echo( "message 1" );
else if( $errorCode = =3D=3D=A0DATETIME_FIELD_OVERFLOW=A0)
=A0=A0 echo( "message 2" );

= -------------------- CODE -------------------------------------------------= --------------


How I can do it?; how I can compare $err= orCode with a Postgres error name ( as in=A0http://www.postgresql.= org/docs/8.1/static/errcodes-appendix.html=A0).

Thank you, again.

On Mon, Sep 21, 2009 at 9:00 PM, Chris <dmagick@gmail.com> wrote:
Gustavo Amarilla Santacruz wrote:
Hello all.

How I can get the postgres error code from PHP?. I can get the error text, = but I need error code to verbose ( and country dependient) messages.

http://www.php.net/manual/en/function.pg-result-er= ror-field.php

seems to be the best fit.

--
Postgresql & php tutorials
http://www.desig= nmagick.com/




--
Gustavo Amarilla=

--000fea892bfb4b8e7404742a6ce1--