tp.5.0.21丟擲錯誤
阿新 • • 發佈:2018-11-19
使用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即可