Viewing the query being run in background

Hi

I Was earlier working in cakephp, now migrating to yii, i have one query, in cakephp when we are working in development mode it is allways showing queries bellow each page that re being fired to database. is it possible;e to view queries in yii some how.

regards

Yes, in config you can enable database profiling and parameter logging (to see bound parameter values). You can setup weblog-routes to display those logs within a page or optionally within Firebug.

Check this links for detailed info:

To get things started, try this in config:




'components' => array(

   ...

   'db' => array(

      ...

      'enableProfiling' => YII_DEBUG,

      'enableParamLogging' => YII_DEBUG,

   ),

   'log' => array(

      'class' => 'CLogRouter',

      'routes' => array(

         array(

            'class' => 'CProfileLogRoute',

            'enabled' => YII_DEBUG,

            //'showInFireBug' => true,

         ),

         array(

            'class' => 'CWebLogRoute',

            'enabled' => YII_DEBUG,

            //'showInFireBug' => true,

      ),

   ),

   ...

),



Is it possible to log, the SQL queries being fired, to a file?

i want to log all the sql queries to a file for later review & tuning.

You can add a route to CFileLogRoute

… and use category ‘system.db.CDbCommand’ if you only want the SQL commands logged.