YII Displays SQL for debugging

Source: Internet
Author: User
Tags yii

To insert a test:

A simple controller:

  function Actionjia () {                    $goods _model = new Goods ();//Add different from query cannot use the following method//                    $goods _model=goods::model ();                    $goods _model->goods_name = ' Apple phone ';                    $goods _model->goods_price = ' 5199 ';                    $goods _model->goods_weight=102;                    Var_dump ($goods _model->save ());                   Var_dump ($goods _model);                    if ($goods _model->save ()) {                        echo ' success ';                    } else{                        echo "error";                    }                                    }
Display the log information at the bottom of the page:


To set the master profile about the DB option:

Such as:

' DB ' =>array (' connectionString ' = ' mysql:host=localhost;dbname=php0507 ', ' emulateprepare ' = ' = True, ' Username ' + ' root ', ' password ' + ', ' charset ' and ' utf8 ', ' tableprefix ' = ' sw_ ',                     //  ' Enableparamlogging ' =>true,//does not display parameter information for SQL statement bindings),

: The reason is that using PDO is a preprocessing, followed by a parameter


After adding:


Why is this set?


main.php the master configuration file loads the DB component, and the DB component is below this path \framework\db


YII Displays SQL for 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.