Re: Dobjects Error Thowing

From: Date: Tue, 17 Jun 2003 16:31:07 +0000
Subject: Re: Dobjects Error Thowing
References: 1  Groups: php.pear.general php.pear.general 
Request: Send a blank email to pear-general+get-6059@lists.php.net to get a copy of this message
Limbourg Arnaud wrote:
oups sorry for the wrong code $dbo->_lastError->getMessage(); The thing is that you are not supposed to access private memebers directly. Alan should be able to give your more info on that.
Technically that is not really private, since dataobjects could define lastError as a valid database column name, links and errors use the 'standard private' notation to store stuff thats not related to the columns. (As I couldnt think of any alternative..) I guess with php5 it'll probably change to $dbo->lastError()->getMessage(); regards Alan
Arnaud.
Hi, Thanks for the suggestion Arnaud. Sadly after executing the $dbCapture->insert() attempting to:- echo $dbCapture->last_error->getMessage(); Just gives me the error:- Fatal error: Call to a member function on a non-object in c:\htdocs\pma\htdocs\front\storedetails.php on line 37 Doing a var_dump($dbCapture) does show that an error message is defined in the class:- ["_lastError"]=> object(pear_error)(7) { ["error_message_prefix"]=> string(0) "" ["mode"]=> int(1) ["level"]=> int(1024) ["code"]=> int(-18) ["message"]=> string(23) "DB Error: no such table" ["userinfo"]=> NULL ["callback"]=> NULL } What is the offical way to check a PEAR classes result is an error, and if so get the error message string back? Regards, Mike C. -----Original Message----- From: LIMBOURG Arnaud [mailto:arnaud.limbourg.prestataire@cegetel.fr] Sent: 17 June 2003 13:25 To: Mike Carter; pear-general@lists.php.net Subject: RE: [PEAR] Dobjects Error Thowing
Hi, I'm just testing my failsafe code for when a DataObject::insert() fails. The method seems to just return key value/false. Yet the documentation @ http://devel.akbkhome.com/peardoc2/package.database.db-dataobj ect.db-dataobj ect.insert.html indicates that an error is thrown. How do I catch the error in PEAR/PHP ? $dbResult = $dbCapture->insert(); Var_dump(PEAR::isError($dbResult));
if (!$dbResult) { die($dbCapture->last_error->getMessage()); } At least that is what i understood from the code. Arnaud. ______________________________________________________________ __________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ______________________________________________________________ __________ --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.489 / Virus Database: 288 - Release Date: 6/10/2003 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.489 / Virus Database: 288 - Release Date: 6/10/2003 ______________________________________________________________ __________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ______________________________________________________________ __________


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