DAL provides a general way for errorhandling. When a function fails DAL returns 'false' when it's no result function or NULL when the function has to produce a result. It also calls it's own error-handler which puts the errormessage in an internal variable. You can look at the value of this variable or customize the error-handling.
When an error occurs DAL saves the error in an internal variable. You can get this errormessage by fetching the value of lastError. This gives you a plain-text message which should explain which error occured.
DAL also gives you the posibillity to customize the error-handler. That means you can use you're own handler to process the error. By example if you want to have the errormessage mailed to you this is the way to let DAL do that. Just create your own function and say to DAL it has to call it instead of it's own handler.
Your function has to comply to the following prototype:
boolean funtionName
(string errorMessage);
/* * My error Handler */ function myErrorHandler($errorMessage) { /* * In here we handle the error. */ } $mydb = new dal; $mydb->setErrorHandler("myErrorHandler"); |
Because DAL doesn't handle the errors anymore lastError won't contain any errors. When you want to look at the errors later on you have to make sure you save it somewhere. |