Yii framework – call controller function from view


public function getLocations($id)
{
$ids= explode(“,”,$id);
foreach($ids as $key=>$val){
$ids[$key]=(int)$val;
}
$data = Yii::app()->db->createCommand()->select (‘GROUP_CONCAT(location_name) as locations’)->from(‘mt_location’)->where(array(‘in’,’mt_location_id’,$ids))->queryRow();
return $data[“locations”];

}

in view file

array(
‘name’=>’mt_location_id’,
‘value’=>’MtGetintouchController::getLocations($data->mt_location_id)’,
),

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s