php 输出 sql语句

第一种方法

$data = M('news')->field("title,date_format(postdate,'%Y-%m-%d') as postdate,content")->where($map)->limit(1)->find();
var_dump( M('news')->_sql());

注: 把 this->display()去掉

第二种方法:

$resultsql= $model-> getLastSql();

原文地址:https://www.cnblogs.com/sunzhenyong/p/4234167.html