Yii view (output) The SQL statement executed on the current page _php tutorial

Source: Internet
Author: User
Tags mysql view yii

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 ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.