Re: PEAR DB errors (numeric)
| From: | Stig S. Bakken | Date: | Thu, 24 Jan 2002 14:40:55 +0000 |
| Subject: | Re: PEAR DB errors (numeric) | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-719@lists.php.net to get a copy of this message | ||
Hi,
Did you try $rst->getCode()?
- Stig
On Thu, 24 Jan 2002, Daniel Swarbrick wrote:
> What is the correct method of getting a numeric DB error, that I can test
> against the DB_ERROR_ constants? I know that I can use $rst->getMessage() to
> return a text error, but these aren't as reliable to test as numerics.
>
> My code is as such:
>
> $rst = $db->query($sql);
> if (DB::isError($rst)) {
> // check error
> if ($rst->code == DB_ERROR_ALREADY_EXISTS) echo "Duplicate key";
> }
>
> After reading much source code, and a few var_dump()'s, it appears that
> $code contains the numeric error code, but I don't want to bet on this if it
> is likely to change.
>
>
>
>
>