Re: PEAR DB errors (numeric)

From: Date: Thu, 24 Jan 2002 21:42:47 +0000
Subject: Re: PEAR DB errors (numeric)
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-729@lists.php.net to get a copy of this message
Thank you. That worked ;-) I didn't look into PEAR.php - was expecting to find it in DB.php and it's derivatives. "Stig S. Bakken" <ssb@alltheweb.com> wrote in message news:Pine.LNX.4.44.0201241540410.2134-100000@kirin.trondheim.fast.no... > 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. > > > > > > > > > > >

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