pg.ddx.io pgsql-php@postgresql.org mailing list archive
help / color / mirror / Atom feedError code
7+ messages / 3 participants
[nested] [flat]
* Error code
@ 2009-09-21 14:56 Gustavo Amarilla Santacruz <gusamasan@gmail.com>
2009-09-22 01:00 ` Re: Error code Chris <dmagick@gmail.com>
0 siblings, 1 reply; 7+ messages in thread
From: Gustavo Amarilla Santacruz @ 2009-09-21 14:56 UTC (permalink / raw)
To: pgsql-php
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.
Thank you, in advance.
-----------------------
Gustavo Amarilla
ISMEB: I am Sorry, My English is Bad.
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Error code
2009-09-21 14:56 Error code Gustavo Amarilla Santacruz <gusamasan@gmail.com>
@ 2009-09-22 01:00 ` Chris <dmagick@gmail.com>
2009-09-22 13:17 ` Re: Error code Gustavo Amarilla Santacruz <gusamasan@gmail.com>
0 siblings, 1 reply; 7+ messages in thread
From: Chris @ 2009-09-22 01:00 UTC (permalink / raw)
To: Gustavo Amarilla Santacruz <gusamasan@gmail.com>; +Cc: pgsql-php
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/
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Error code
2009-09-21 14:56 Error code Gustavo Amarilla Santacruz <gusamasan@gmail.com>
2009-09-22 01:00 ` Re: Error code Chris <dmagick@gmail.com>
@ 2009-09-22 13:17 ` Gustavo Amarilla Santacruz <gusamasan@gmail.com>
2009-09-22 13:38 ` Re: Error code Bill Moran <wmoran@potentialtech.com>
0 siblings, 1 reply; 7+ messages in thread
From: Gustavo Amarilla Santacruz @ 2009-09-22 13:17 UTC (permalink / raw)
To: Chris <dmagick@gmail.com>; +Cc: 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
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Error code
2009-09-21 14:56 Error code Gustavo Amarilla Santacruz <gusamasan@gmail.com>
2009-09-22 01:00 ` Re: Error code Chris <dmagick@gmail.com>
2009-09-22 13:17 ` Re: Error code Gustavo Amarilla Santacruz <gusamasan@gmail.com>
@ 2009-09-22 13:38 ` Bill Moran <wmoran@potentialtech.com>
2009-09-22 14:20 ` Re: Error code Gustavo Amarilla Santacruz <gusamasan@gmail.com>
0 siblings, 1 reply; 7+ messages in thread
From: Bill Moran @ 2009-09-22 13:38 UTC (permalink / raw)
To: Gustavo Amarilla Santacruz <gusamasan@gmail.com>; +Cc: pgsql-php
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/
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Error code
2009-09-21 14:56 Error code Gustavo Amarilla Santacruz <gusamasan@gmail.com>
2009-09-22 01:00 ` Re: Error code Chris <dmagick@gmail.com>
2009-09-22 13:17 ` Re: Error code Gustavo Amarilla Santacruz <gusamasan@gmail.com>
2009-09-22 13:38 ` Re: Error code Bill Moran <wmoran@potentialtech.com>
@ 2009-09-22 14:20 ` Gustavo Amarilla Santacruz <gusamasan@gmail.com>
2009-09-22 15:08 ` Re: Error code Bill Moran <wmoran@potentialtech.com>
0 siblings, 1 reply; 7+ messages in thread
From: Gustavo Amarilla Santacruz @ 2009-09-22 14:20 UTC (permalink / raw)
To: Bill Moran <wmoran@potentialtech.com>; +Cc: pgsql-php
Thank you, Bill.
I can not use the numeric error code such as 23505 ( by coding convention );
I need to do this:
------------------------ 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
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Error code
2009-09-21 14:56 Error code Gustavo Amarilla Santacruz <gusamasan@gmail.com>
2009-09-22 01:00 ` Re: Error code Chris <dmagick@gmail.com>
2009-09-22 13:17 ` Re: Error code Gustavo Amarilla Santacruz <gusamasan@gmail.com>
2009-09-22 13:38 ` Re: Error code Bill Moran <wmoran@potentialtech.com>
2009-09-22 14:20 ` Re: Error code Gustavo Amarilla Santacruz <gusamasan@gmail.com>
@ 2009-09-22 15:08 ` Bill Moran <wmoran@potentialtech.com>
2009-09-22 15:54 ` Re: Error code Gustavo Amarilla Santacruz <gusamasan@gmail.com>
0 siblings, 1 reply; 7+ messages in thread
From: Bill Moran @ 2009-09-22 15:08 UTC (permalink / raw)
To: Gustavo Amarilla Santacruz <gusamasan@gmail.com>; +Cc: pgsql-php
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/
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Error code
2009-09-21 14:56 Error code Gustavo Amarilla Santacruz <gusamasan@gmail.com>
2009-09-22 01:00 ` Re: Error code Chris <dmagick@gmail.com>
2009-09-22 13:17 ` Re: Error code Gustavo Amarilla Santacruz <gusamasan@gmail.com>
2009-09-22 13:38 ` Re: Error code Bill Moran <wmoran@potentialtech.com>
2009-09-22 14:20 ` Re: Error code Gustavo Amarilla Santacruz <gusamasan@gmail.com>
2009-09-22 15:08 ` Re: Error code Bill Moran <wmoran@potentialtech.com>
@ 2009-09-22 15:54 ` Gustavo Amarilla Santacruz <gusamasan@gmail.com>
0 siblings, 0 replies; 7+ messages in thread
From: Gustavo Amarilla Santacruz @ 2009-09-22 15:54 UTC (permalink / raw)
To: Bill Moran <wmoran@potentialtech.com>; +Cc: pgsql-php
Thank you, all.
I will have all proposals in mind.
On Tue, Sep 22, 2009 at 11:08 AM, Bill Moran <wmoran@potentialtech.com>wrote:
> 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/<http://people.collaborativefusion.com/%7Ewmoran/;
> > >
> >
> >
> >
> > --
> > Gustavo Amarilla
> > ISMEB
>
>
> --
> Bill Moran
> http://www.potentialtech.com
> http://people.collaborativefusion.com/~wmoran/<http://people.collaborativefusion.com/%7Ewmoran/;
>
--
Gustavo Amarilla
ISMEB
^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2009-09-22 15:54 UTC | newest]
Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2009-09-21 14:56 Error code Gustavo Amarilla Santacruz <gusamasan@gmail.com>
2009-09-22 01:00 ` Chris <dmagick@gmail.com>
2009-09-22 13:17 ` Gustavo Amarilla Santacruz <gusamasan@gmail.com>
2009-09-22 13:38 ` Bill Moran <wmoran@potentialtech.com>
2009-09-22 14:20 ` Gustavo Amarilla Santacruz <gusamasan@gmail.com>
2009-09-22 15:08 ` Bill Moran <wmoran@potentialtech.com>
2009-09-22 15:54 ` Gustavo Amarilla Santacruz <gusamasan@gmail.com>
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