我在CakePHP 1.3文档中读到conditions
的{{1}}参数等同于SQL find()
子句。我想在CakePHP中写这样的东西:
WHERE
但是,我对如何构造 select count(*) from claim
where ((claim_id = X and company_id = W) or (claimant_firstName = Y and claimant_lastName = Z))
参数感到困惑。
是不是
conditions
或
find('count', array(
'conditions' => array(
Claim.company_id => $companyId,
Claim.id' => $claimNumber,
'or' => array(
'Claimant.first_name' => $claimantFirstName,
'Claimant.last_name' => $claimantLastName,
)
)
)
);
或其他完全不同的东西?
答案 0 :(得分:1)
试试这个:
$conditions = array(
'or' => array (
array( 'and' => array( 'Claim.company_id' => $companyId, 'Claim.id' => $claimNumber )),
array( 'and' => array( 'Claimant.first_name' => $claimantFirstName, 'Claimant.last_name' => $claimantLastName ))
)
);
$this->ModelName->find('count', array( 'conditions' => $conditions ));