SELECT COUNT GROUP BY

How to construct the following query

[sql]SELECT status,COUNT(*) as count FROM users GROUP BY status[/sql]

with the "User" AR model of the users table, the most efficient way?

Done it by using DAO instead, it uses less RAM.

Can you post what exactly you did?

Something like:




$dbCommand = Yii::app()->db->createCommand("

   SELECT status,COUNT(*) as count FROM `users` GROUP BY `status`

");


$data = $dbCommand->queryAll();



then in the views,it can user <?php foreach $data as ($n=>$dat):?>to display the data?