RE: [PEAR] error returning with PEAR::DB
| From: | Torsten Roehr | Date: | Tue, 30 Mar 2004 20:40:27 +0000 |
| Subject: | RE: [PEAR] error returning with PEAR::DB | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-11547@lists.php.net to get a copy of this message | ||
> 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!';
> }
It could also be DB_ERROR_ALREADY_EXISTS. That's what DB in connection with
my MySQL server returns.
Regards,
Torsten Roehr