简体   繁体   English

这是使用find的正确CakePHP内部联接吗?

[英]Is this a proper CakePHP inner join using find?

This is what I want to do: 这就是我想做的:

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

This is what i have so far: 这是我到目前为止所拥有的:

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
    )
));

What am I doing wrong? 我究竟做错了什么?

If don't pass it the type value it will use LEFT JOIN by default. 如果不传递type值,则默认使用LEFT JOIN。 See this link 看到这个链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM