I have the following code to get some records from db
$criteria = new CDbCriteria();
$criteria->condition = \'t.date BETWEEN \"\'.$from_date.\'\"
If you don't want to execute the query before seeing the SQL, this isn't actually as easy as you might hope.
It's as dirty as wrong but, when in development only, I have in the past taken to adding a deliberate a deliberate error in the criteria and relying on the resulting Exception to give the SQL attempted.
e.g.
$criteria = new CDbCriteria();
$criteria->condition = 't.date_fgjhfgjfgj BETWEEN :from_date AND :to_date';
$criteria->params = array(
':from_date' => $from_date,
':to_date' => $to_date,
);
$criteria->with = array('order');
$orders = ProductOrder::model()->findAll($criteria);
I have found Ilya's method to be unreliable (don't know why, but sometimes the criteria is ignored using this method).