![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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. |
#3
| |||
| |||
|
|
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/ |
#4
| |||
| |||
|
|
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 ) |
#5
| |||
| |||
|
#6
| |||
| |||
|
|
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 (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 |
#7
| ||||
| ||||
|
|
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/ |
|
In response to Gustavo Amarilla Santacruz <<a href=3D"mailto:gusamasan@= gmail.com">gusamasan (AT) gmail (DOT) com</a>>:<br |
|
I can not use the numeric error code such as 23505 ( by coding convent= ion );<br I need to do this:<br 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 (DOT) com">wmo...tech (DOT) com</a>>wrote:<br br In response to Gustavo Amarilla Santacruz <<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 |
![]() |
| Thread Tools | |
| Display Modes | |
| |