How to dump yii AR query?

How to see what is the AR query?

example:


$data = User::model()->with(array('logger'=>array('joinType'=>'LEFT JOIN')))->findall(array("order"=>"logger.ipcim desc","limit"=>1));

result:

select * from user

inner join logger

oder by logger.ipcim desc

limit 1

You can use profiling to show all your queries and the time needed for execution: http://www.yiiframework.com/doc/guide/1.1/en/topics.logging#profiling-sql-executions

Thanks, any solution? var_dump?

You can add CWebLogRoute in the config to see the queries

Yes, i see querys. But dont have yii any solutions?

There is no better way that I know of, despite some hacks with beforeFind() and creating SQL out of the CDbCriteria object there, but that’s most certainly not what you want. The ProfileLogRoute really is the best way to check queries imho.

btw. This extension could be of interest for you: http://www.yiiframework.com/extension/yii-debug-toolbar

I’m actually disappointed if there’s no way to see queries during execution. I know you can use the built-in profilers, but it doesn’t help if you like to program in debug mode like I do.

I use Codeigniter for work, and it’s extremely helpful to be able to just add a $this->db->last_query() watch whenever needed.

Why isn’t this already in Yii?

You should make a thread in the Feature request forum, it seems usefull.

Sorry Speeedfire.Yii Dont have any gud solution for this problem.Which i am also facing since from last 1+ year.But if your using sql statements instead of PDO or DAO statements then You can check Your Queries with var_dump.

But still its not a perfect solution for this problem.