How to print the executed sql string from active record ?

Hi guys, I have seen here somewhere about printing the executed sql from an active record, but I think I’ve lost it, searched but can’t find it. So, please how do I return the sql string executed from ActiveRecord ?


The easiest is to active CWebLogRoute. It adds debugging output to the bottom of every page.

You can also set enableParamLogging=>true in your db component configuration.

Hey Mike, thanks, that I knew. I guess, I want to hear the hardest one ? ???

What about within phpunit test scripts when you want to print it to the console or display in some other way?