在cakephp中的控制器上按id显示名称

时间:2013-10-24 17:00:21

标签: cakephp cakephp-2.0

如何通过ID显示列表中的名称。代码如下。

$allocationIds = $this->Staff->StaffAllocation->find('list',array(
                         'fields'=>array('StaffAllocation.group_id' ), 
                         'conditions'=>$conditions));

此处输出

Array
(
    [7] => 5
)

此处5是来自字段分配的组ID

'fields'=>array('StaffAllocation.group_id' ),

这里我们需要

Array
(
    [7] => group name
)

因为我们与StaffAllocation

的群组表有关系

0 个答案:

没有答案