Often when I am using ActiveRecords and need to debug the data or errors that I am receiving, I have wanted some way to see the "raw" sql that is generated and executed after all conditions, etc. have been applied. Is there a way to do this?
I know that the CActiveRecord class uses the CDbCommandBuilder class to incorporate any criteria passed to it through a find() command. CDbCommandBuilder returns a CDbCommand object, which has a public property "text" that contains the raw sql that I am looking for, but I can see no way to access this property buried in there when working with AR. If it is not possible to access this property directly, is there some way to turn on a "display sql" debug mode?
Thanks in advance for any ideas or tips you may have.
Wow! I should really go back and re-read the "definitive guide to Yii"!
I did have logging enabled and configured, but only for errors and warnings, so never saw any SQL statements in there and didn't realize that getting that data was even possible through Yii logging. I now have the "trace" option in my "levels" parameter. That was exactly what I needed.
Sorry to ask a question that had an “rtfm” answer. Thanks for the help.