cakephp打印sql语句的方法


本文实例讲述了cakephp打印sql语句的方法。分享给大家供大家参考。具体实现方法如下:

将以下语句复制到你的代码中,可以打印出在这之前所有的sql语句:

$sources = ConnectionManager::sourceList(); 
if (!isset($logs)): 
$logs = array(); 
foreach ($sources as $source): 
$db =& ConnectionManager::getDataSource($source); 
if (!$db->isInterfaceSupported('getLog')): 
continue; 
endif; 
$logs[$source] = $db->getLog(); 
endforeach; 
endif;

希望本文所述对大家基于cakePHP框架的php程序设计有所帮助。


« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3