Skip site navigation (1) Skip section navigation (2)

Re: Error code

From: Gustavo Amarilla Santacruz <gusamasan(at)gmail(dot)com>
To: Chris <dmagick(at)gmail(dot)com>
Cc: pgsql-php(at)postgresql(dot)org
Subject: Re: Error code
Date: 2009-09-22 13:17:21
Message-ID: e4ea2d810909220617s63921795nedc17fa61b7d49f9@mail.gmail.com (view raw or flat)
Thread:
Lists: 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(at)gmail(dot)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

In response to

Responses

pgsql-php by date

Next:From: Bill MoranDate: 2009-09-22 13:38:15
Subject: Re: Error code
Previous:From: ChrisDate: 2009-09-22 01:00:45
Subject: Re: Error code

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group