Re: error returning with PEAR::DB
| From: | Martin Marques | Date: | Wed, 31 Mar 2004 12:20:53 +0000 |
| Subject: | Re: error returning with PEAR::DB | ||
| References: | 1 2 3 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-11554@lists.php.net to get a copy of this message | ||
On Tue, 30 Mar 2004, Lukas Smith wrote:
> Pupeno wrote:
>
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> >
> > On Tuesday 30 March 2004 17:03, Torsten Roehr wrote:
> >
> >>The only problem I see is that you cannot check WHICH error occurred.
> >
> > Well, that's the key... I catch any error to throw an unexpected error, do
> > some logging latter and so on... If i was to throw a "username in use" error,
> > then, I should be sure that it was a "username in use" error.
>
> I would expect the error code to match the DB_ERROR_CONSTRAINT constant.
>
> if(DB::isError($result) && $result->getCode() == DB_ERROR_CONSTRAINT) {
> echo 'contraint violation!';
> }
This doesn't necessarily tell you that the UNIQUE user constraint was
violated, only that "a contraint violation occured".
--
09:15:02 up 22 days, 13:43, 3 users, load average: 0.02, 0.05, 0.01
-----------------------------------------------------------------
Martín Marqués | select 'mmarques' || '@' || 'unl.edu.ar'
Centro de Telematica | DBA, Programador, Administrador
Universidad Nacional
del Litoral
-----------------------------------------------------------------