NIUCLOUD是一款SaaS管理后台框架多应用插件+云编译。上千名开发者、服务商正在积极拥抱开发者生态。欢迎开发者们免费入驻。一起助力发展! 广告
1. 首先引入Log类:`use think\Log;` 2. 其次在调用模型查询或者修改方法之后调用日志记录调试执行的SQL语句 ~~~ <?php namespace app\index\model; use app\common\model\RemoteModel; use think\Config; use think\Log; class DCharacter extends RemoteModel { /** * 等级人数计算 * * @param int $level 等级 * @return int 等级分布人数 */ public function doLevelCount($level) { $map['level'] = $level; $count = $this->where($map)->count('level'); Log::info(self::getLastSql()); //调试SQL return $count; } } ~~~