Home > Backend Development > PHP Tutorial > Yii views (outputs) the sql statements executed by the current page_PHP tutorial

Yii views (outputs) the sql statements executed by the current page_PHP tutorial

WBOY
Release: 2016-07-13 09:56:48
Original
1277 people have browsed it

Yii views (outputs) the sql statements executed on the current page

This article shares how to view all sql statements executed on the current page under the Yii framework, mainly by configuring related files To achieve the purpose of debugging sql, the specific method is as follows:

(1) Modify index.php to enable debugging mode

Add the following two lines of code in the index.php file (if it does not exist):

//开启调试模式
defined('YII_DEBUG') or define('YII_DEBUG',true);
//设置日志记录级别,YII_TRACE_LEVEL的数字越大,信息越清楚
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);
Copy after login

(2) Modify the configuration file main.php

Add the following array under components - log - routes in config/main.php:

array(  
	'class'=>'CFileLogRoute',//文件记录日志的形式
	'levels'=>'trace',//日志记录级别
	'categories'=>'system.db.*',//只显示关于数据库信息,包括数据库连接,数据库执行语句
	'logFile' => 'app_'.date('Y-m-d').'.log',//日志保存文件名
	'logPath'=>'D:\phpStudy\WWW\phpernote\com\tmpfile\log_db',//日志保存路径
),
Copy after login

ok, after the above settings, refresh the page, you can go to the directory D:phpStudyWWWphpernotecomtmpfilelog_db to find the generated sql record file. The output log format is as follows:

[Time] - [Level] - [Category] - [Content]

2015/04/17 10:30:51 [trace] [system.db.CDbCommand] Querying SQL: SELECT * FROM `phpernote_article` ORDER BY id desc LIMIT 15

Articles you may be interested in

  • mysql View the currently running sql statement
  • PHP Get the complete url address function of the current page, including parameters
  • How to view the database table The current self-increment value
  • How to know which SQL statements in the database are executed slowly
  • How to use zlib to compress output content to improve the speed of opening web pages
  • Linux checks how many lines a file has, Detailed explanation of linux wc command
  • How to check the current running status of memcache through the command line
  • js outputs the current time in a timely manner

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/985844.htmlTechArticleYii View (output) the sql statements executed by the current page. This article shares all the sql statements executed by the current page under the Yii framework. The sql statement method mainly achieves debugging by configuring related files...
Related labels:
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template