tp.5.0.21抛出错误

使用Exception类,抛出错误。

<?php
namespace app\admin\controller;
use think\Db;
use think\Exception;
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即可

posted @ 2018-11-19 11:53  瑛雄  阅读(909)  评论(0编辑  收藏  举报