1、fetchSql(),数据表和DB类都能调用,案例如下:
public function index(){
$res=Db::name('test2')->fetchSql()->find(1);
$res2=Db::name('test')->fetchSql()->find(3);
halt($res,$res2);//输出结果,并中断执行
}
可以看到对应的sql信息。
2、也可以使用getLastSql(),不过该方法只能获得最后一条的信息:
public function index(){
$res=Db::name('test2')->fetchSql()->find(1);
Db::name('test')->fetchSql()->find(3);
echo Db::getLastSql();
halt($res);//输出结果,并中断执行
}