Home > php教程 > php手册 > body text

cakephp打印sql语句的方法

WBOY
Release: 2016-06-13 09:14:37
Original
1856 people have browsed it

cakephp打印sql语句的方法

 这篇文章主要介绍了cakephp打印sql语句的方法,可实现打印输出之前全部SQL语句的功能,具有一定参考借鉴价值,需要的朋友可以参考下

 

 

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

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

?

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程序设计有所帮助。

source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template