emmi
(Qshefa)
1
following is my query how do i place what code in view ,model,controller in yii
select productid, count(*)
from fc_member
group by productid
order by count(*)desc
LIMIT 3
Please let me know i am a newbie
i did try but then do not the how and what of it 
masterq
(Masterq)
2
You could try with createCommand method:
$result= Yii::app()->db->createCommand()
->select('productid, COUNT(*) as count')
->from('fc_member')
->group('productid ')
->limit(3)
->queryAll();
emmi
(Qshefa)
3
thankx master Q
the thing is i have to display the result in gridview
in view displayproducts
<?php
$this->widget('zii.widgets.grid.CGridView', array(
'id' => 'detail-grid',
'dataProvider' => $dataProvider,
'filter' => $dataProvider,
'columns' => array(
'productid',
'count',
),));
in controller actiondisplayproduct
/*the Controller*/
$dataProvider=new CActiveDataProvider('$model',
array(
'criteria'=>array(
'select'=>'productid, count(*) as count',
'from'=>'fc_members',
'group'=>'productid',
'order'=>'count(*) Desc LIMIT 3',
),
)
);
$this->render('displayproduct',array(
'dataProvider'=>$dataProvider,
));
but then i its not working out 