Yii view (output) The SQL statement executed by the current page
This article shares the method of viewing all SQL statements executed by the current page under the YII framework, mainly by configuring related files to achieve the purpose of debugging SQL, as follows:
(1) Modify index.php Open Debug mode
Add the following two lines of code (if not present) in the index.php file:
Turn on debug mode defined (' Yii_debug ') or define (' Yii_debug ', true);//Set logging level, the greater the number of yii_trace_level, the clearer the information defined (' Yii_trace _level ') or define (' Yii_trace_level ', 3);
(2) Modify the configuration file main.php
Add the following array to the config/main.php components-log-routes:
Array ( ' class ' = ' Cfilelogroute ',//File log form ' levels ' = ' trace ',//logging level ' categories ' = ' system.db.* ', Displays only information about the database, including database connections, database execution statement ' logFile ' = ' app_ '. Date (' y-m-d '). Log ',//Logs Save file name ' LogPath ' = ' D:\phpStudy\WWW\phpernote\com\tmpfile\log_db ',//Log save path,
OK, after the above settings, refresh the page, you can go to the D:\phpStudy\WWW\phpernote\com\tmpfile\log_db directory 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 Gets the current page full URL address function, including parameters
- How to view the current self-increment of a database table
- How to know that the SQL statements executed in the database are slow
- How to use zlib to compress output content to improve Web page opening speed
- Linux view file How many lines, Linux WC command detailed
- How to view the current running state of memcache from the command line
- JS timely output The current time
http://www.bkjia.com/PHPjc/985844.html www.bkjia.com true http://www.bkjia.com/PHPjc/985844.html techarticle yii View (output) The SQL statement executed on the current page This article shares the method of viewing all the SQL statements executed by the current page under the YII framework, mainly by configuring the relevant files to achieve debugging ...