how to write criteria for this Query.
No need of CreateCommand.
/***************
select * from(SELECT * FROM table
order by created_time
DESC) as Table1 group by Column_1
;
******************/
how to write criteria for this Query.
No need of CreateCommand.
/***************
select * from(SELECT * FROM table
order by created_time
DESC) as Table1 group by Column_1
;
******************/
If I understood U right:
[indent][/indent]$criteria = new CDbCriteria();
[indent][/indent]$criteria->order = ‘created_time DESC’;
[indent][/indent]$criteria->group = ‘Column_1’;
[indent][/indent]$result = Table1::model()->findAll($criteria);
Also U should check this:
My link
Thanks for Your Reply. My Query is Solved
When you use "group by" you should specify a grouping function like count(*). You can do this:
$criteria = new CDbCriteria();
$criteria->select = 'post_id, count(*) as postCount'; // The attribute 'postCount' should be defined on the model
$criteria->order = 'created_time DESC';
$criteria->group = 'postCount';
$result = Post::model()->findAll($criteria);