How to show insert query generated through $model->save() function

别等时光非礼了梦想. 提交于 2019-12-22 14:47:22

问题


I want to show the query which is generated when we call the function $model->save() of a model. I did not find any way to do it. If anyone knows please reply.

Thanks


回答1:


Change your 'db' component in your config file -

'db'=>array(
         …
        'enableProfiling'=>true,
        'enableParamLogging' => true,
),

Then check wherever you are logging everything. If file, it will be application.log file. Else on the page itself. To enable logging in file -

    'log'=>array(
      'class'=>'CLogRouter',
    'routes'=>array(
            array(
                'class'=>'CWebLogRoute',                    
                'levels'=>'trace, info, error, warning',
        ),
            array(
                'class'=>'CFileLogRoute',  
                // 'categories' => 'system.db.*',
                'levels'=>'trace, info, error, warning',    
            ),

        ),


来源:https://stackoverflow.com/questions/9598179/how-to-show-insert-query-generated-through-model-save-function

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!