Un modo ancora più "semplice", che però può causare una marea di messaggi, è inviare una mail con l'errore...
Nel gestore delle query si fa qualcosa del tipo
Codice PHP:
if (! $this->query_id )
{
$this->fatal_error("mySQL query error: $the_query");
}
Codice PHP:
private function fatal_error($the_error="")
{
$this->error = $this->_get_error_string();
$this->error_no = $this->_get_error_number();
$the_error = "
[b]" . $the_error . "[/b]
";
$the_error .= "[b]SQL error:[/b] ".$this->error."
";
$the_error .= "[b]SQL error code[/b]: ".$this->error_no."
";
$the_error .= "[b]Date:[/b] ".date("l dS \o\f F Y h:i:s A") . "
";
$trace = $this->superGestore->getDebugBacktrace();
$this->superGestore->Error($the_error . $trace);
exit();
}
Codice PHP:
private function _get_error_string()
{
if( $this->connect_failed )
{
return mysqli_connect_error( );
}
else
{
return mysqli_error( $this->connection_id );
}
}
private function _get_error_number()
{
if( $this->connect_failed )
{
return mysqli_connect_errno( );
}
else
{
return mysqli_errno( $this->connection_id );
}
}
superGestore
Codice PHP:
function getDebugBacktrace($NL = "
") {
$dbgTrace = debug_backtrace();
$dbgMsg .= $NL."<h5>[b]Debug backtrace begin:[/b]</h5><ul>";
foreach($dbgTrace as $dbgIndex => $dbgInfo) {
$dbgMsg .= "[*]at $dbgIndex [i]".$dbgInfo['file']."[/i] (line {$dbgInfo['line']}) -> <u>{$dbgInfo['function']}</u>";
}
$dbgMsg .= "[/list]<h5>[b]Debug backtrace end[/b]</h5>".$NL;
return $dbgMsg;
}
e la funzione Error non fa altro che inviare la mail.
Questo metodo lo uso molto, ma solo quando sono in produzione. Nelle fasi di test è eccessivo, basta una segnalazione a video