PEAR DB errors (numeric)

From: Date: Thu, 24 Jan 2002 06:49:17 +0000
Subject: PEAR DB errors (numeric)
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-713@lists.php.net to get a copy of this message
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.

« previous php.pear.general (#713) next »