这是一个使用find的合适的CakePHP内连接吗?

时间:2011-11-17 02:57:40

标签: php cakephp cakephp-1.3 cakephp-2.0

这就是我想要做的事情:

SELECT * FROM `potential_matches` INNER JOIN release ON release.asin = potential_matches.asin WHERE release.id = 6;

这是我到目前为止所做的:

class Release extends AppModel {
    public $actsAs = array('Containable');
    public $hasMany = array('PotentialMatch');
}

class PotentialMatch extends AppModel {
    public $actsAs = array('Containable');
    public $belongsTo = array('Release');
}


$this->Release->find('all', array(
    'contain' => array('PotentialMatch')
    'conditions' => array(
        'Message.to' => 6
    )
));

我做错了什么?

1 个答案:

答案 0 :(得分:0)

如果不传递type值,默认情况下它将使用LEFT JOIN。见link