Php 更详细的例外情况

Php 更详细的例外情况,php,pdo,Php,Pdo,我几乎已经完成了将我的旧sql网站转换为pdo,以移动到php7并使用准备好的语句,但是我遇到了一些错误。 异常并不像我希望的那样清楚,大多数错误都指向我的数据库类,例如 Uncaught Exception: 2020-01-18 20:23:35 - SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corres

我几乎已经完成了将我的旧sql网站转换为pdo,以移动到php7并使用准备好的语句,但是我遇到了一些错误。 异常并不像我希望的那样清楚,大多数错误都指向我的数据库类,例如

Uncaught Exception: 2020-01-18 20:23:35 - SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'username' AND UNIX_TIMESTAMP('2020-01-18 20:23:35')-UNIX_TIMESTAMP(date) < 30' at line 1 in file /home/test/public_html/backend/dbclass.php on line 39
Uncaught Exception: 2020-01-18 20:23:43 - SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '86.28.135.16'', donated=0, forumbanned='no', warned='no', modcomment='', enabled' at line 1 in file /home/test/public_html/backend/dbclass.php on line 39
查询示例

$stmt = DB::run("SELECT word FROM censor ORDER BY word");
while ($row = $stmt->fetch())

您发布的代码不支持错误消息。因此,我可以澄清被问到的问题:您想了解有关查询中错误的更多详细信息吗?如果是这样,我不确定这是否可能——错误消息已经尽可能详细了。如果您需要查看更多的堆栈跟踪,那么请尝试这篇正确的文章。我希望在错误发生之前看到出现了什么问题,但我更希望不要使用services,而不是错误地说dbclass如果它指向像staff.php之类的php页面,它会有所帮助
function handleUncaughtException($e){
    // Show general page to public
    header("Location: exceptionerror.php"); 
    // Construct the error string
    $error = "Uncaught Exception: " . $message = date("Y-m-d H:i:s - ");
    $error .= $e->getMessage() . " in file " . $e->getFile() . " on line " . $e->getLine() . "\n";

    // Log details of error in a file
    error_log($error, 3, "error_log.txt");
}
// Register custom exception handler
set_exception_handler("handleUncaughtException");
$stmt = DB::run("SELECT word FROM censor ORDER BY word");
while ($row = $stmt->fetch())