我需要使用CakePHP查找方法执行以下查询:
SELECT * FROM `ads`
INNER JOIN fields_values ON fields_values.ref_id = ad.id
WHERE ad.active = 1
我试过这个功能,但她没有工作:
$ads = $this->Ad->find('all', array(
'joins' => array(
array(
'table' => 'fields_values',
'alias' => 'fv',
'type' => 'INNER',
'conditions' => array(
"Ad.id = fv.ref_id "
)
)
),
'conditions' => array(
'Ad.active' => 1
),
));