对不起,如果这是显而易见的 - 我试图做一个连接表上的find()和失败,什么是正确的语法来做到这一点?CakePHP在连接表上查找
基本上我有费用表与HABTM与费用表的关系。
在我expenseCode模型我有:
public function beforeDelete($cascade = false) {
$count = $this->Expense->find("count", array(
'conditions' => array('expense_code_id' => $this->id)
));
if ($count == 0) {
return true;
} else {
//$this->Session->setFlash('Record cannot be deleted as it has ' . $count . 'number of expenses attached to it');
return false;
}
}
如果我取消了setFlash()我得到的错误。
我哪里错了?提前致谢。
所以应该有不匹配expense_code_ids这 - > ID? 语法看起来正确,并且查找正在工作,但至少发现一个结果 – Quinny