我尝试了很多场景,但失败了。
我需要使用属于模型来映射3个帐户。
$conditions['OR']['ClientActuarialForm.abn'] = $keyword;
$conditions['OR']['ClientActuarialForm.certificate_display_id'] = $keyword;
$conditions['OR']['ClientActuarialForm.id'] = $memberMatches;
$conditions['OR']['ClientActuarialForm.fund_name LIKE'] = '%' . $keyword . '%';
$this->ClientActuarialForm->belongsTo['ClientClassRequest'] = [
"foreignKey" => false,
"conditions" => array("ClientClassRequest.smsf_actuarial_form_id = ClientActuarialForm.id"),
];
$this->ClientActuarialForm->belongsTo['GroupAccount'] = [
"foreignKey" => false,
"conditions" => array("GroupAccount.id = ClientActuarialForm.created_group_account_id"),
];
现在,我需要添加一个条件
$conditions['OR']['Account.email LIKE'] = '%' . $this->Account->encrypt($keyword) . '%';
需要将2个表格映射到 ClientActuarialForm 。
是下表GroupAccountToApprovedCustomerUser
帐户
数据库
ClientActuarialForm - 在评论框中给出
现在我指出,如果关键字是电子邮件ID,那么我需要在帐户ID表中搜索电子邮件ID。account.email = keyword
使用第二个表格中的帐户ID搜索组帐户ID(GroupAccountToApprovedCustomerUser)(即)GroupAccountToApprovedCustomerUser.customer_id = Account.id
使用群组帐户ID在ClientActuarialForm中查找表单数据ClientActuarialForm.created_group_account_id = GroupAccountToApprovedCustomerUser.group_account_id