tp.5.0.21抛出错误

使用Exception类,抛出错误。

<?php
namespace appadmincontroller;
use thinkDb;
use thinkException;
class Admin
{
    private $user_id;
    //构造函数
    public function __construct() 
    {
        $this->user_id = 'ss';
    }


    public function index()
    {
        try{
            $res = Db::table('admin')->where(['id'=>2])->update(['username2'=>'admin123']);
        }catch(Exception $e){
            $res = $e->getMessage();
        }
        print_r($res);
        exit;
    }

}

上面代码打印结果是 : fields not exists:[username2];

但是并没有显示多少行,下面需要在设置里面设置下,能看到具体哪一行错误!

application下的config文件,把    'app_debug'              => true,       'show_error_msg'         => true,  这两项都设置为true即可

原文地址:https://www.cnblogs.com/lyzaidxh/p/9982355.html