Basic MySQL Query

Can’t seem to figure this one out. I want to generate an array to be used by dropDownList. The data is in a table called ‘locations’, in a field called ‘loc_name’.

I want to generate an array with each row from this table, as follows:




return array(

	Location::model()->loc_name => Location::model()->loc_name,

);



Check "Example 4: Using data from db" in http://www.yiiframework.com/doc/cookbook/48/




echo CHtml::activeDropDownList($model, 'loc_name', CHtml::listData(Location::model()->findAll(), 'loc_name', 'loc_name'));



Cheers mbi.

Is it possible to do this in a function, that I can put inside the Property model?

I want to be able to generate the dropDownList like this:




<?php echo CHtml::dropDownList('location', $_GET['location'], Property::model()->getLocations()); ?>