SQL Debugging..

I am trying out the nestedset extension only now I get a error:




CDbCommand failed to execute the SQL statement: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '>= '0' AND right <= '1' ORDER BY left ASC' at line 1



How do I set it so debugging shows the entire query ?

First of all enable logging.

Add to protected/config/main.php,

to the ‘components’ section (e.g. for web and file logging):




  'log'=>array(

    'class'=>'CLogRouter',

    'routes'=>array(

      array(

        'class'=>'CWebLogRoute',  'levels'=>'trace, info, error, warning',

      ),

      array(

        'class'=>'CFileLogRoute',  'levels'=>'trace, info, error, warning',

      ),

    )

  )



to the ‘preload’ section:




  'preload'=>array('log'),



File logging to protected/runtime/application.log

/Tommy

Ah thanks works very good :D I see can add…

‘categories’ => ‘system.db.*’,

To have it log only database ^^

is there a way to log insert queries too? I have a query that is succesfull… but some fields do not get updated…

is there?

just set logging traces to file. add to config/main.php

‘log’=>array(

        'class'=&gt;'CLogRouter',


        'routes'=&gt;array(


            array(


                'class'=&gt;'CFileLogRoute',


                'levels'=&gt;'trace, info, error, warning',


            ),

This works just fine on the front end, however I see nothing when viewing pages in a module.

How do I turn this on for my module?

Ignore that… it is working in my module.

BUT… it does nothing when loading CGridView using filters.

How can I see database queries when filtering in CGridview?