这篇文章主要介绍了cakephp打印sql语句的方法,可实现打印输出之前全部sql语句的功能,具有一定参考借鉴价值,需要的朋友可以参考下
本文实例讲述了cakephp打印sql语句的方法。分享给大家供大家参考。具体实现方法如下:
将以下语句复制到你的代码中,可以打印出在这之前所有的sql语句:
?
立即学习“PHP免费学习笔记(深入)”;
|
1 2 3 4 5 6 7 8 9 10 11 |
$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 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号