Answer the question
In order to leave comments, you need to log in
How to return results by ignoring empty sql conditions?
$result = Company::model()->with(
'staffs',
'staffs.phoneStaffs',
'staffs.emailStaffs'
)->findAll(array(
'condition'=> 'staffs.client_id=:idClientId '
. 'and phoneStaffs.client_id=:idClientId '
. 'and emailStaffs.client_id=:idClientId',
'params'=> array(':idClientId' => $idClientId)));
Answer the question
In order to leave comments, you need to log in
$result = Company::find()
->with(['staffs', 'staffs.phoneStaffs', 'staffs.emailStaffs'])
->filterWhere([
'staffs.client_id' => $idClientId,
'phoneStaffs.client_id' => $idClientId,
'emailStaffs.client_id' => $idClientId,
])->all();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question