Error code

--000feaf2043943436c047417b077
Content-Type: text/plain; charset=ISO-8859-1

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.

--000feaf2043943436c047417b077
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hello all.<div><br></div><div>How I can get the postgres error code from PH=
P?. I can get the error text, but I need error code to verbose ( and countr=
y dependient) messages.</div><div><br></div><div>Thank you, in advance.</di=
v>

<div><br></div><div><br></div><div>-----------------------=A0</div><div>Gus=
tavo Amarilla</div><div>ISMEB: I am Sorry, My English is Bad.<br><br>
</div>

--000feaf2043943436c047417b077--
Gustavo Amarilla Sant [ Mo, 21 September 2009 16:56 ] [ ID #2016719 ]

Re: Error code

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/


--
Sent via pgsql-php mailing list (pgsql-php [at] postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-php
dmagick [ Di, 22 September 2009 03:00 ] [ ID #2016720 ]

Re: Error code

--000fea892bfb4b8e7404742a6ce1
Content-Type: text/plain; charset=ISO-8859-1

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.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

--000fea892bfb4b8e7404742a6ce1
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Thank you, Chris.<div><br></div><div>Now, I need to do this in PHP:</div><d=
iv><br></div><div>-------------------- CODE -------------------------------=
--------------------------------</div><div><br></div><div><font class=3D"Ap=
ple-style-span" face=3D"'courier new', monospace">$errorCode =3D=A0=
pg_result_error_field($res1, PGSQL_DIAG_SQLSTATE) ;</font></div>

<div><font class=3D"Apple-style-span" face=3D"'courier new', monosp=
ace"><br></font></div><div><font class=3D"Apple-style-span" face=3D"'co=
urier new', monospace">if( $errorCode =3D=3D UNIQUE_VIOLATION )</font><=
/div><div>

<font class=3D"Apple-style-span" face=3D"'courier new', monospace">=
=A0=A0 echo( "message 1" );</font></div><div><font class=3D"Apple=
-style-span" face=3D"'courier new', monospace">else if( $errorCode =
=3D=3D=A0</font><span class=3D"Apple-style-span" style=3D"font-size: 12px; =
-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2p=
x; "><font class=3D"Apple-style-span" face=3D"'courier new', monosp=
ace">DATETIME_FIELD_OVERFLOW=A0</font><span class=3D"Apple-style-span" styl=
e=3D"font-size: small; -webkit-border-horizontal-spacing: 0px; -webkit-bord=
er-vertical-spacing: 0px; "><font class=3D"Apple-style-span" face=3D"'c=
ourier new', monospace">)</font></span></span></div>

<div><font class=3D"Apple-style-span" face=3D"'courier new', monosp=
ace">=A0=A0 echo( "message 2" );</font></div><div><br></div><div>=
-------------------- CODE -------------------------------------------------=
--------------</div>

<div><br></div><div><br></div><div>How I can do it?; how I can compare <fon=
t class=3D"Apple-style-span" face=3D"'courier new', monospace">$err=
orCode</font> with a Postgres error name ( as in=A0<a href=3D"http://www.po=
stgresql.org/docs/8.1/static/errcodes-appendix.html">http:// www.postgresql.=
org/docs/8.1/static/errcodes-appendix.html</a>=A0).</div>

<div><br></div><div>Thank you, again.</div><div><br><div class=3D"gmail_quo=
te">On Mon, Sep 21, 2009 at 9:00 PM, Chris <span dir=3D"ltr"><<a href=3D=
"mailto:dmagick [at] gmail.com" target=3D"_blank">dmagick [at] gmail.com</a>></spa=
n> wrote:<br>


<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div>Gustavo Amarilla Santacruz wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">
Hello all.<br><br>
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.<br>
</blockquote>
<br>
</div><a href=3D"http://www.php.net/manual/en/function.pg-result-error-fiel=
d.php" target=3D"_blank">http://www.php.net/manual/en/function.pg-r esult-er=
ror-field.php</a><br>
<br>
seems to be the best fit.<br><font color=3D"#888888">
<br>
-- <br>
Postgresql & php tutorials<br>
<a href=3D"http://www.designmagick.com/" target=3D"_blank">http://www.desig=
nmagick.com/</a><br>
<br>
</font></blockquote></div><br><br clear=3D"all"><br>-- <br>Gustavo Amarilla=
<br><br>
</div>

--000fea892bfb4b8e7404742a6ce1--
Gustavo Amarilla Sant [ Di, 22 September 2009 15:17 ] [ ID #2016721 ]

Re: Error code

In response to Gustavo Amarilla Santacruz <gusamasan [at] 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/

--
Sent via pgsql-php mailing list (pgsql-php [at] postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-php
Bill Moran [ Di, 22 September 2009 15:38 ] [ ID #2016722 ]

Re: Error code

--00c09f88d0f31e851d04742b4de1
Content-Type: text/plain; charset=ISO-8859-1

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 [at] potentialtech.com>wrote:

> In response to Gustavo Amarilla Santacruz <gusamasan [at] 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

--00c09f88d0f31e851d04742b4de1
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Thank you, Bill.<div><br></div><div>I can not use the numeric error code su=
ch as=A023505 ( by coding convention ); I need to do this:</div><div><br></=
div><div><br></div><div>------------------------ CODE ---------------------=
--------------------------------------</div>

<div><br></div><div><div><font class=3D"Apple-style-span" face=3D"'cour=
ier new', monospace">include( "PostgresqlErrorList.php" );</f=
ont></div><div><span class=3D"Apple-tab-span" style=3D"white-space:pre"><fo=
nt class=3D"Apple-style-span" face=3D"'courier new', monospace"> </=
font></span></div>

<div><span class=3D"Apple-tab-span" style=3D"white-space:pre"><font class=
=3D"Apple-style-span" face=3D"'courier new', monospace"> </font></s=
pan><font class=3D"Apple-style-span" face=3D"'courier new', monospa=
ce">.</font></div>

<div><span class=3D"Apple-tab-span" style=3D"white-space:pre"><font class=
=3D"Apple-style-span" face=3D"'courier new', monospace"> </font></s=
pan><font class=3D"Apple-style-span" face=3D"'courier new', monospa=
ce">.</font></div>

<div><span class=3D"Apple-tab-span" style=3D"white-space:pre"><font class=
=3D"Apple-style-span" face=3D"'courier new', monospace"> </font></s=
pan><font class=3D"Apple-style-span" face=3D"'courier new', monospa=
ce">.</font></div>

<div><span class=3D"Apple-tab-span" style=3D"white-space:pre"><font class=
=3D"Apple-style-span" face=3D"'courier new', monospace"> </font></s=
pan></div><div><span class=3D"Apple-tab-span" style=3D"white-space:pre"><fo=
nt class=3D"Apple-style-span" face=3D"'courier new', monospace"> </=
font></span><font class=3D"Apple-style-span" face=3D"'courier new',=
monospace">if( $errorCode =3D=3D $UNIQUE_VIOLATION )</font></div>

<div><span class=3D"Apple-tab-span" style=3D"white-space:pre"><font class=
=3D"Apple-style-span" face=3D"'courier new', monospace"> </font></=
span><font class=3D"Apple-style-span" face=3D"'courier new', monosp=
ace">echo( "message" );</font></div>

</div><div><br></div><div><br></div><div><br></div><div><br></div><div>----=
-------------------- CODE -------------------------------------------------=
----------</div><div><br></div><div><br></div><div>Here, "PostgresqlEr=
rorList.php" is a file included in =A0PHP libraries. This file would c=
an contain code such as:</div>

<div><br></div><div><br></div><div><br></div><div><font class=3D"Apple-styl=
e-span" face=3D"'courier new', monospace"><php?</font></div><div=
><font class=3D"Apple-style-span" face=3D"'courier new', monospace"=
>=A0=A0 =A0$UNIQUE_VIOLATION =A0 =A0 =A0=3D 23505;</font></div>

<div><font class=3D"Apple-style-span" face=3D"'courier new', monosp=
ace">=A0=A0 =A0$</font><span class=3D"Apple-style-span" style=3D"font-size:=
12px; border-collapse: collapse; "><font class=3D"Apple-style-span" face=
=3D"'courier new', monospace">DATETIME_FIELD_OVERFLOW=A0</font></sp=
an><font class=3D"Apple-style-span" face=3D"'courier new', monospac=
e">=A0=3D 22008;</font></div>

<div><font class=3D"Apple-style-span" face=3D"'courier new', monosp=
ace">=A0=A0 .</font></div><div><font class=3D"Apple-style-span" face=3D"=
9;courier new', monospace">=A0=A0 .</font></div><div><font class=3D"App=
le-style-span" face=3D"'courier new', monospace">=A0=A0 .</font></d=
iv>

<div><font class=3D"Apple-style-span" face=3D"'courier new', monosp=
ace">?></font></div><div><br></div><div><br></div><div>Exists this file =
for in Postgresql-PHP library?</div><div><br><div class=3D"gmail_quote">On =
Tue, Sep 22, 2009 at 9:38 AM, Bill Moran <span dir=3D"ltr"><<a href=3D"m=
ailto:wmoran [at] potentialtech.com">wmoran [at] potentialtech.com</a>></span> wro=
te:<br>

<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex;">In response to Gustavo Amarilla Santacruz &=
lt;<a href=3D"mailto:gusamasan [at] gmail.com">gusamasan [at] gmail.com</a>>:<br>
<div class=3D"im"><br>
> Thank you, Chris.<br>
> Now, I need to do this in PHP:<br>
><br>
> -------------------- CODE<br>
> ------------------------------------------------------------ ---<br>
><br>
> $errorCode =3D pg_result_error_field($res1, PGSQL_DIAG_SQLSTATE) ;<br>
><br>
> if( $errorCode =3D=3D UNIQUE_VIOLATION )<br>
<br>
</div>if ( $errorCode =3D=3D '23505' )<br>
<font color=3D"#888888"><br>
--<br>
Bill Moran<br>
<a href=3D"http://www.potentialtech.com" target=3D"_blank">http://www.poten=
tialtech.com</a><br>
<a href=3D"http://people.collaborativefusion.com/~wmoran/" target=3D"_blank=
">http://people.collaborativefusion.com/~wmoran/</a><br>
</font></blockquote></div><br><br clear=3D"all"><br>-- <br>Gustavo Amarilla=
</div><div>ISMEB<br><br>
</div>

--00c09f88d0f31e851d04742b4de1--
Gustavo Amarilla Sant [ Di, 22 September 2009 16:20 ] [ ID #2016723 ]

Re: Error code

In response to Gustavo Amarilla Santacruz <gusamasan [at] 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 [at] potentialtech.com>wrote:
>
> > In response to Gustavo Amarilla Santacruz <gusamasan [at] 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/

--
Sent via pgsql-php mailing list (pgsql-php [at] postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-php
Bill Moran [ Di, 22 September 2009 17:08 ] [ ID #2016724 ]

Re: Error code

--000feae9fe125ce2cb04742c9e74
Content-Type: text/plain; charset=ISO-8859-1

Thank you, all.

I will have all proposals in mind.

On Tue, Sep 22, 2009 at 11:08 AM, Bill Moran <wmoran [at] potentialtech.com>wrote:

> In response to Gustavo Amarilla Santacruz <gusamasan [at] 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 [at] potentialtech.com
> >wrote:
> >
> > > In response to Gustavo Amarilla Santacruz <gusamasan [at] 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

--000feae9fe125ce2cb04742c9e74
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Thank you, all.<br><br>I will have all proposals in mind.<br><br><div class=
=3D"gmail_quote">On Tue, Sep 22, 2009 at 11:08 AM, Bill Moran <span dir=3D"=
ltr"><<a href=3D"mailto:wmoran [at] potentialtech.com">wmoran [at] potentialtech.c=
om</a>></span> wrote:<br>

<blockquote class=3D"gmail_quote" style=3D"border-left: 1px solid rgb(204, =
204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class=3D"im"=
>In response to Gustavo Amarilla Santacruz <<a href=3D"mailto:gusamasan [at] =
gmail.com">gusamasan [at] gmail.com</a>>:<br>


<br>
</div><div class=3D"im">> Thank you, Bill.<br>
> I can not use the numeric error code such as 23505 ( by coding convent=
ion );<br>
> I need to do this:<br>
<br>
</div>That's fine. =A0Note, however, that those codes are not numeric.<=
br>
Also, you'll be better served putting them in constants, to avoid<br>
bugs where the values are accidentally changed.<br>
<div><div></div><div class=3D"h5"><br>
><br>
><br>
> ------------------------ CODE<br>
> -----------------------------------------------------------<br>
><br>
> include( "PostgresqlErrorList.php" );<br>
> =A0.<br>
> =A0.<br>
> =A0.<br>
> =A0if( $errorCode =3D=3D $UNIQUE_VIOLATION )<br>
> =A0echo( "message" );<br>
><br>
><br>
><br>
><br>
> ------------------------ CODE<br>
> -----------------------------------------------------------<br>
><br>
><br>
> Here, "PostgresqlErrorList.php" is a file included in =A0PHP=
libraries. This<br>
> file would can contain code such as:<br>
><br>
><br>
><br>
> <php?<br>
> =A0 =A0 $UNIQUE_VIOLATION =A0 =A0 =A0=3D 23505;<br>
> =A0 =A0 $DATETIME_FIELD_OVERFLOW =A0=3D 22008;<br>
> =A0 =A0.<br>
> =A0 =A0.<br>
> =A0 =A0.<br>
> ?><br>
><br>
><br>
> Exists this file for in Postgresql-PHP library?<br>
><br>
> On Tue, Sep 22, 2009 at 9:38 AM, Bill Moran <<a href=3D"mailto:wmor=
an [at] potentialtech.com">wmoran [at] potentialtech.com</a>>wrote:<br>
><br>
> > In response to Gustavo Amarilla Santacruz <<a href=3D"mailto:g=
usamasan [at] gmail.com">gusamasan [at] gmail.com</a>>:<br>
> ><br>
> > > Thank you, Chris.<br>
> > > Now, I need to do this in PHP:<br>
> > ><br>
> > > -------------------- CODE<br>
> > > ------------------------------------------------------------ =
---<br>
> > ><br>
> > > $errorCode =3D pg_result_error_field($res1, PGSQL_DIAG_SQLST=
ATE) ;<br>
> > ><br>
> > > if( $errorCode =3D=3D UNIQUE_VIOLATION )<br>
> ><br>
> > if ( $errorCode =3D=3D '23505' )<br>
> ><br>
> > --<br>
> > Bill Moran<br>
> > <a href=3D"http://www.potentialtech.com" target=3D"_blank">http:/=
/www.potentialtech.com</a><br>
> > <a href=3D"http://people.collaborativefusion.com/%7Ewmoran/" targ=
et=3D"_blank">http://people.collaborativefusion.com/~wmoran/</a><br>
> ><br>
><br>
><br>
><br>
> --<br>
> Gustavo Amarilla<br>
> ISMEB<br>
<br>
<br>
</div></div>--<br>
<div><div></div><div class=3D"h5">Bill Moran<br>
<a href=3D"http://www.potentialtech.com" target=3D"_blank">http://www.poten=
tialtech.com</a><br>
<a href=3D"http://people.collaborativefusion.com/%7Ewmoran/" target=3D"_bla=
nk">http://people.collaborativefusion.com/~wmoran/</a><br>
</div></div></blockquote></div><br><br clear=3D"all"><br>-- <br>Gustavo Ama=
rilla<br>ISMEB<br>

--000feae9fe125ce2cb04742c9e74--
Gustavo Amarilla Sant [ Di, 22 September 2009 17:54 ] [ ID #2016725 ]
Datenbanken » gmane.comp.db.postgresql.php » Error code

Vorheriges Thema: checking select query syntax and semantics via php without executing
Nächstes Thema: pg_connect() error