0
User Table -
column name - location_id
values = 4,5
Location table
column name - id , location_name
values = 4 nagpur
5, Akola
我想通过加入用户表的LOCATION_ID,以显示在列表框的位置名称,使用来自两个表中提取在列表框的值加入
假设在用户表中的LOCATION_ID柱4,5的值都存在,那么在我选择框只显示位置表中的nagpur,Akola。
我无法理解如何在选择前展开location_id表的值,并且只显示位置表中location_id列中可用的那些值。
public function getUserLocations() {
$this->loadModel('User');
$getlocations = $this->User->find('list', array(
'fields' => array('Location.id','Location.location_name'),
'joins' => array(
array(
'table' => 'locations',
'alias' => 'Location',
'type' => 'LEFT',
'conditions' => array('FIND_IN_SET(User.location_id,Location.id)')
)
),
));
$this->set('getlocations', $getlocations);
}
下面是我的代码..
在数组中,是表=位置还是位置?最后一个在位置... –
阵列中的值来自位置 –