dbTalk Databases Forums  

[PHP] Error code

mailing.database.pgsql-php mailing.database.pgsql-php


Discuss [PHP] Error code in the mailing.database.pgsql-php forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Gustavo Amarilla Santacruz
 
Posts: n/a

Default [PHP] Error code - 09-21-2009 , 07:16 PM






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

Reply With Quote
  #2  
Old   
Chris
 
Posts: n/a

Default Re: [PHP] Error code - 09-21-2009 , 08:03 PM






Gustavo Amarilla Santacruz wrote:
Quote:
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/functio...rror-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 (DOT) org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-php

Reply With Quote
  #3  
Old   
Gustavo Amarilla Santacruz
 
Posts: n/a

Default Re: [PHP] Error code - 09-22-2009 , 08:18 AM



--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/s...-appendix.html ).

Thank you, again.

On Mon, Sep 21, 2009 at 9:00 PM, Chris <dmagick (AT) gmail (DOT) com> wrote:

Quote:
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/functio...rror-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( &quot;message 1&quot; );</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( &quot;message 2&quot; );</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">&lt;<a href=3D=
"mailto:dmagick (AT) gmail (DOT) com" target=3D"_blank">dmagick (AT) gmail (DOT) com</a>&gt;</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-result-er=
ror-field.php</a><br>
<br>
seems to be the best fit.<br><font color=3D"#888888">
<br>
-- <br>
Postgresql &amp; 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--

Reply With Quote
  #4  
Old   
Bill Moran
 
Posts: n/a

Default Re: [PHP] Error code - 09-22-2009 , 08:38 AM



In response to Gustavo Amarilla Santacruz <gusamasan (AT) gmail (DOT) com>:

Quote:
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 (DOT) org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-php

Reply With Quote
  #5  
Old   
Gustavo Amarilla Santacruz
 
Posts: n/a

Default Re: [PHP] Error code - 09-22-2009 , 09:21 AM



--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" );

Reply With Quote
  #6  
Old   
Bill Moran
 
Posts: n/a

Default Re: [PHP] Error code - 09-22-2009 , 10:09 AM



In response to Gustavo Amarilla Santacruz <gusamasan (AT) gmail (DOT) com>:

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

Quote:

------------------------ 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 (DOT) com>wrote:

In response to Gustavo Amarilla Santacruz <gusamasan (AT) gmail (DOT) 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 (DOT) org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-php

Reply With Quote
  #7  
Old   
Gustavo Amarilla Santacruz
 
Posts: n/a

Default Re: [PHP] Error code - 09-22-2009 , 10:55 AM



--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 (DOT) com>wrote:

Quote:
In response to Gustavo Amarilla Santacruz <gusamasan (AT) gmail (DOT) 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 (DOT) com
wrote:

In response to Gustavo Amarilla Santacruz <gusamasan (AT) gmail (DOT) 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">&lt;<a href=3D"mailto:wmoran (AT) potentialtech (DOT) com">wmoran (AT) potentialtech (DOT) c=
om</a>&gt;</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"=
Quote:
In response to Gustavo Amarilla Santacruz &lt;<a href=3D"mailto:gusamasan@=
gmail.com">gusamasan (AT) gmail (DOT) com</a>>:<br


<br>
</div><div class=3D"im">&gt; Thank you, Bill.<br>
Quote:
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>
Quote:
br
br
------------------------ CODE<br
-----------------------------------------------------------<br
br
include( &quot;PostgresqlErrorList.php&quot; );<br
=A0.<br
=A0.<br
=A0.<br
=A0if( $errorCode =3D=3D $UNIQUE_VIOLATION )<br
=A0echo( &quot;message&quot; );<br
br
br
br
br
------------------------ CODE<br
-----------------------------------------------------------<br
br
br
Here, &quot;PostgresqlErrorList.php&quot; is a file included in =A0PHP=
libraries. This<br
file would can contain code such as:<br
br
br
br
&lt;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 &lt;<a href=3D"mailto:wmor=
an (AT) potentialtech (DOT) com">wmo...tech (DOT) com</a>>wrote:<br
br
In response to Gustavo Amarilla Santacruz &lt;<a href=3D"mailto:g=
usamasan (AT) gmail (DOT) com">gusam...mail (DOT) 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--

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.