pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bill Moran <wmoran@potentialtech.com>
To: Gustavo Amarilla Santacruz <gusamasan@gmail.com>
Cc: pgsql-php@postgresql.org
Subject: Re: Error code
Date: Tue, 22 Sep 2009 11:08:35 -0400
Message-ID: <20090922110835.a8c5b2b4.wmoran@potentialtech.com> (raw)
In-Reply-To: <e4ea2d810909220720i38860764sd5366878325cd4f2@mail.gmail.com>
References: <e4ea2d810909210756s547417d6x7ecfb1d8300623e8@mail.gmail.com>
	<4AB821BD.6070508@gmail.com>
	<e4ea2d810909220617s63921795nedc17fa61b7d49f9@mail.gmail.com>
	<20090922093815.7b8ae05f.wmoran@potentialtech.com>
	<e4ea2d810909220720i38860764sd5366878325cd4f2@mail.gmail.com>

In response to Gustavo Amarilla Santacruz <gusamasan@gmail.com>:

> Thank you, Bill.
> I can not use the numeric error code such as 23505 ( by coding convention );
> I need to do this:

That's fine.  Note, however, that those codes are not numeric.
Also, you'll be better served putting them in constants, to avoid
bugs where the values are accidentally changed.

> 
> 
> ------------------------ CODE
> -----------------------------------------------------------
> 
> include( "PostgresqlErrorList.php" );
>  .
>  .
>  .
>  if( $errorCode == $UNIQUE_VIOLATION )
>  echo( "message" );
> 
> 
> 
> 
> ------------------------ CODE
> -----------------------------------------------------------
> 
> 
> Here, "PostgresqlErrorList.php" is a file included in  PHP libraries. This
> file would can contain code such as:
> 
> 
> 
> <php?
>     $UNIQUE_VIOLATION      = 23505;
>     $DATETIME_FIELD_OVERFLOW  = 22008;
>    .
>    .
>    .
> ?>
> 
> 
> Exists this file for in Postgresql-PHP library?
> 
> On Tue, Sep 22, 2009 at 9:38 AM, Bill Moran <wmoran@potentialtech.com>wrote:
> 
> > In response to Gustavo Amarilla Santacruz <gusamasan@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 )
> >
> > if ( $errorCode == '23505' )
> >
> > --
> > Bill Moran
> > http://www.potentialtech.com
> > http://people.collaborativefusion.com/~wmoran/
> >
> 
> 
> 
> -- 
> Gustavo Amarilla
> ISMEB


-- 
Bill Moran
http://www.potentialtech.com
http://people.collaborativefusion.com/~wmoran/



view thread (7+ messages)  latest in thread

Message-ID: <20090922110835.a8c5b2b4.wmoran@potentialtech.com>
Permalink:  ../20090922110835.a8c5b2b4.wmoran@potentialtech.com/
Also on:    postgresql.org/message-id/20090922110835.a8c5b2b4.wmoran@potentialtech.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: wmoran@potentialtech.com, gusamasan@gmail.com
  Subject: Re: Error code
  In-Reply-To: <20090922110835.a8c5b2b4.wmoran@potentialtech.com>
  References: <e4ea2d810909210756s547417d6x7ecfb1d8300623e8@mail.gmail.com> <4AB821BD.6070508@gmail.com> <e4ea2d810909220617s63921795nedc17fa61b7d49f9@mail.gmail.com> <20090922093815.7b8ae05f.wmoran@potentialtech.com> <e4ea2d810909220720i38860764sd5366878325cd4f2@mail.gmail.com> <20090922110835.a8c5b2b4.wmoran@potentialtech.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