I have a search function, which works great for staff, so I can search by name. Now, I want filter staffs by staffgroup.groupname, but unfortunatelly i get this error:
Column not found: 1054 Unknown column 'staffgroups.groupname' in 'where clause'
I'm having the following tablelayout
- staffs (a person can belong to many groups)
- staff_staffgroups (HABTM-linking table)
- staffgroups (has a groupname)
i used the conditions as follows:
$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());
I cant manage to get it working, allthough i think the Condition is set right.
cheers endo
var_dump($this->StaffGroup->find('all');
? – Lorenzen