Im new in Yii and object oriented,i need some help on how to display the data from controller into layout/main.php.The table called branch and i need to display a dropdownlist at the layout.However, it returns error.Please help me.Here is the code,
protected/controllers/BranchController.php:
public static function BranchList()
{
$myList = "SELECT branch_name FROM branch";
$rows = Yii::app()->db->createCommand($myList)->queryAll();
return array($rows);
}
protected/views/layout/main.php:
<?php
$optd = CHtml::listData(BranchController::BranchList());
echo CHtml::dropDownList('listname','branch',array($optd));
?>