Re: Error code - Mailing list pgsql-php

From Gustavo Amarilla Santacruz
Subject Re: Error code
Date
Msg-id e4ea2d810909220617s63921795nedc17fa61b7d49f9@mail.gmail.com
Whole thread Raw
In response to Re: Error code  (Chris <dmagick@gmail.com>)
Responses Re: Error code
List pgsql-php
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 <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-error-field.php

seems to be the best fit.

--
Postgresql & php tutorials
http://www.designmagick.com/




--
Gustavo Amarilla

pgsql-php by date:

Previous
From: Chris
Date:
Subject: Re: Error code
Next
From: Bill Moran
Date:
Subject: Re: Error code