activeDropDownList

I have a problem filling a array from a query for a activeDropDownList

I used the code


 $rows=array();

        $sql='select cmp_id,cmp_name from companies order by cmp_name ';

        $command=Yii::app()->db->createCommand($sql);

        $row=$command->query();   

       $rows=$row->readAll();

        return $rows;

.......

echo CHtml::activeDropDownList($model,'usr_type',$type); 



As $type is the $rows but the drop down does not fill as expected.

What is wrong.

You have to use CHtml::listData() before forwarding all your rows.

[Edit] I solved it.

so I write


    public function  returnCompanies() {

$rows=array();

        $sql='select cmp_id,cmp_name from companies order by cmp_name ';

        $command=Yii::app()->db->createCommand($sql);       

       $rows=$command->queryAll();;

        return $rows;

}

....

  $cmps=CHtml::listData(companies::model()->returnCompanies(),'cmp_id','cmp_name') ;



But ther is no difference.

The print_r is