Thinkphp3.2版
echo D(‘user’)->getLastSql();
Thinkphp5.0版
//前面加上引用的类库
use think\Db;
//输出语句
echo Db::table(‘table_name’)->getLastSql();
Laravel框架
DB::connection()->enableQueryLog(); // 开启QueryLog
\App\User::find(1);
dump(DB::getQueryLog());
Thinkphp3.2版
echo D(‘user’)->getLastSql();
Thinkphp5.0版
//前面加上引用的类库
use think\Db;
//输出语句
echo Db::table(‘table_name’)->getLastSql();
Laravel框架
DB::connection()->enableQueryLog(); // 开启QueryLog
\App\User::find(1);
dump(DB::getQueryLog());