pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Gustavo Amarilla Santacruz <gusamasan@gmail.com>
To: Chris <dmagick@gmail.com>
Cc: pgsql-php@postgresql.org
Subject: Re: Error code
Date: Tue, 22 Sep 2009 09:17:21 -0400
Message-ID: <e4ea2d810909220617s63921795nedc17fa61b7d49f9@mail.gmail.com> (raw)
In-Reply-To: <4AB821BD.6070508@gmail.com>
References: <e4ea2d810909210756s547417d6x7ecfb1d8300623e8@mail.gmail.com>
	<4AB821BD.6070508@gmail.com>

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

view thread (7+ messages)  latest in thread

Message-ID: <e4ea2d810909220617s63921795nedc17fa61b7d49f9@mail.gmail.com>
Permalink:  ../e4ea2d810909220617s63921795nedc17fa61b7d49f9@mail.gmail.com/
Also on:    postgresql.org/message-id/e4ea2d810909220617s63921795nedc17fa61b7d49f9@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: gusamasan@gmail.com, dmagick@gmail.com
  Subject: Re: Error code
  In-Reply-To: <e4ea2d810909220617s63921795nedc17fa61b7d49f9@mail.gmail.com>
  References: <e4ea2d810909210756s547417d6x7ecfb1d8300623e8@mail.gmail.com> <4AB821BD.6070508@gmail.com> <e4ea2d810909220617s63921795nedc17fa61b7d49f9@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox