Hi. I have this problem regarding foreign keys.
I have four (4) tables.
-
Server
-
Patching (scheduling)
-
Os
-
OsVersion
Server → os_id
Server → os_version_id
Patching → server_id
In Patching, I would like to view the (os_id → os_name) and (os_version_id → os_version_name) but I can’t. I can only get the upto the ID of each table.
I did this in my view.php:
<?php $this->widget('zii.widgets.CDetailView', array(
'data'=>$model,
'attributes'=>array(
array('label'=>'Operating System','value'=>CHtml::encode(ServerInventory::model()->findByPk($model->server_inventory_id)->os_id)),
array('label'=>'Operating System Version','value'=>CHtml::encode(ServerInventory::model()->findByPk($model->server_inventory_id)->os_version_id)),
),
)); ?>
And I already did this in Patching’s model:
public function relations()
{
return array(
'server_inventory'=>array(self::BELONGS_TO,'ServerInventory','server_inventory_id'),
'os'=>array(self::BELONGS_TO,'Os','os_id'),
'os_version'=>array(self::BELONGS_TO,'OsVersion','os_version_id'),
);
}
Hope someone could help me. Thanks in advance!
[color="#FFFF00"]//I’m sorry this shouldn’t be under Installation and Setup Category. [/color]