Home  >  Article  >  php教程  >  cakephp打印sql语句的方法,cakephpsql语句

cakephp打印sql语句的方法,cakephpsql语句

WBOY
WBOYOriginal
2016-06-13 09:14:271475browse

cakephp打印sql语句的方法,cakephpsql语句

本文实例讲述了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程序设计有所帮助。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn