i'm trying to make a litle search action for one of my Model.
My Model Salarie
was associated with some other models, in particular :
-
Salarie
-> hasMany ->Permission
-
Salarie
-> hasOne ->Carburant
So i try to make a find() on my Model Salarie
to select records that match a keyword.
This keyword can by found in my model Salarie
, or in associated model Permission
, Carburant
.
Here is my actual find() :
$salaries = $this->Salarie->find('all',array(
'contain' => array(
'User','Agence','Entitee','Fonction','Contact','Ligne','Car','CallingCard','Badge','Carburant','Permission'),
'conditions'=>array(
'OR'=>array(
'Salarie.nom LIKE' => '%'.$keyWord.'%',
'Salarie.prenom LIKE' => '%'.$keyWord.'%',
'Salarie.secu LIKE' => '%'.$keyWord.'%',
'Salarie.tel LIKE' => '%'.$keyWord.'%',
'Salarie.mobile LIKE' => '%'.$keyWord.'%',
'Salarie.ville LIKE' => '%'.$keyWord.'%',
'Salarie.email LIKE' => '%'.$keyWord.'%',
'Carburant.numero LIKE' => '%'.$keyWord.'%',
)
)
));
This code works but doesn't looks into Permission
table/model, if i add this line
'Permission.login LIKE' => '%'.$keyWord.'%',
in my conditions array i got a error
Column not found: 1054 Unknown column 'Permission.login' in 'where clause'
I've try with contain
but it's not what i looking for, contain
filters datas into the results of the find
.
if someone got a tips ?