Best Way To Implement Select * From (Select...

Hello everyone,

I have a not so complex query, but I’m not sure how to implement, as I can’t use, as I have seen in the documentation, a CDbCriteria object. Query is:


SELECT * FROM (SELECT * FROM record_has_revision ORDER BY changed DESC) as record_has_revision GROUP BY id_record ORDER BY changed DESC

As you can see, I’m trying to get latest changed records… Problem is, is there a way to make this query and pass the results as it would be a CActiveDataProvider object?

An why do you not use a SqlDataProvider?

Mainly because I want to use the results in a CListView, and want to pass a CActiveDataProvider… Is it possible to use CSqlDataProvider with CListView?

Yes, It is.

http://www.yiiframework.com/forum/index.php/topic/34259-clistview-and-csqldataprovider/page__p__164895__hl__CSqlDataProvider+CLi+tView#entry164895