MySQL Forums
Forum List  »  PHP

Re: Automatic notification of errors with your MySQL database
Posted by: Chis Florinel
Date: August 29, 2005 05:33AM

You solution can create a huge spam:
what happens if you have in a page with 100 mysql_query(), and all queries fail, and to spice it up, the page is getting accessed 100 times/minute.
How many emails you receive? What happens to your mail server and your mailbox?

A better solution is using a database abstraction layer for mysql, with error reporting implemented as class method:
class dbMySQL
{

//.....

function raiseError()
{
//
//here create message, maybe display it to user saying that the admin has beed notified and he should try again later
//log it in a table/file (if possible)
//check for spam (mails sent to admin should be logged)
//notify the admin by email or other ways: sms, net send, etc...
}
//...


}
as class, or Exception
( http://www.php.net/~helly/php/ext/spl/classException.html)
derivated class (Creole has something like that implemented):

http://koders.com/php/fidC3C897243FDB1B5666C4B5237CA52696124414FA.aspx?s=%22SQLException+extends+Exception%22

(binarycloud is a framework that uses Creole for database access)

I didn't post any php code, because the approach depends on each application type.

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.