假设以下表格:
如何在BusinessesReview上调用'find',以便只选择那些用户从业务状态说出DIFFERS的条目?
$this->BusinessesReview->contain(array('BusinessesProfile'=>array('BusinessesLocation'),'User'=>array('UsersLocation')));
$results = $this->BusinessesReview->find('all', array('conditions'=>array('BusinessesLocation.location_state_id <> UsersLocation.location_state_id')));
给出错误:
MySQL Error: 1054: Unknown column 'BusinessesLocation.location_state_id'
答案 0 :(得分:0)
您需要将此信息放入contain
来电
$this->BusinessesReview->contain(
array(
'BusinessesProfile' => array(
'BusinessesLocation' => array(
'conditions' => array(
'BusinessesLocation.location_state_id <> UsersLocation.location_state_id'
)
)
),
... // rest of the array goes here
)
);
回答评论:尝试将User
数组放在BusinessesProfile
的{{1}}数组之前。这是一个黑暗的镜头,但我猜这可能会设置您的contain()
首先被查询,为您提供UsersLocation
查询的必要信息。