Here are tables/models:
Attachment 2078 not found.
I want to combine (common hp_id and up_id) models and show it with CGridView.
How to get the models correctly related?
Here are tables/models:
Attachment 2078 not found.
I want to combine (common hp_id and up_id) models and show it with CGridView.
How to get the models correctly related?
Just use relations with the Model. This guide will help you out…
I am not understanding: you want toshow a value of a foreign key?
//Example relationships in model
//Hope you have correctly created models with relationships
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'files' => array(self::HAS_MANY, 'Files', 'nodes_id'),
'contentTypes' => array(self::BELONGS_TO, 'ContentTypes', 'content_types_id'),
'nodeTypes' => array(self::BELONGS_TO, 'NodeTypes', 'node_types_id'),
'sites' => array(self::BELONGS_TO, 'Sites', 'sites_id'),
);
}
//combining them and creating dataprovider
$criteria=new CDbCriteria;
$criteria->with = array('sites', 'nodeTypes', 'contentTypes');
$dataProviderExpCamp=new CActiveDataProvider('Campaign', array('criteria'=>$criteria));
//Retreive in gridview
array('name'=>'node_types_id',
'value'=>'$data->nodeTypes->name'),
NOTE: merged duplicate posts