我有一个搜索功能,非常适合员工,所以我可以按姓名搜索。现在,我想通过 staffgroup.groupname 过滤员工,但不幸的是我收到了这个错误:
Column not found: 1054 Unknown column 'staffgroups.groupname' in 'where clause'
我有以下表格布局
- 员工(一个人可以属于多个组)
- staff_staffgroups(HABTM 链接表)
- staffgroups(有组名)
我使用的条件如下:
$tmpConditions['AND'][] = array('Staff.isActive =' => "1");
$tmpConditions['OR'][] = array('Staff.lastname LIKE' => "%$name%");
$tmpConditions['OR'][] = array('staffgroups.groupname LIKE' => "%$group%");
[...]
$this->Staff->recursive = 1;
$this->paginate = array('conditions' => $tmpConditions );
$this->set('staffs', $this->paginate());
我无法让它工作,尽管我认为条件设置正确。
干杯