簡體   English   中英

哎呀抓住PDO錯誤?

[英]Whoops to catch PDO errors?

我在我的網站上使用了whoops ,現在我嘗試使用PDO錯誤,當缺少連接數據庫的信息時,它可以正常工作,但當你(作為一個例子)鍵入一個不存在的表時,它會' t顯示錯誤。

我試着將PrettyPageHandler::addDataTable()添加到我的錯誤handel

db.php中

class db {

    // just some not important code here...

    // Try to get the result from database.
    try {
        $pdo = DB::getInstance()->db->prepare($sql);
        $pdo->execute($execute);
        $result = $pdo->fetchAll(PDO::FETCH_ASSOC);
        // Return Result
        return $result;
    }
    catch(PDOException $e)
    {
        PrettyPageHandler::addDataTable(null, $e);
    }
}

的index.php

<?php
if(file_exists("plugins/whoops/autoload.php"))
{
    require_once 'plugins/whoops/autoload.php';
    $whoops = new \Whoops\Run;
    $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler);
    $whoops->register();
}

require_once db.php';

$db = new db();

但后來我找不到類'PrettyPageHandler'了

您需要使用完整的類名use語句。 更改PrettyPageHandler::addDataTable(null, $e); to \\Whoops\\Handler\\PrettyPageHandler::addDataTable(null, $e);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM