比较cakephp中两个数据库的数据

时间:2013-12-17 15:13:02

标签: cakephp-1.3

我想在CakePHP中写下以下内容:

(select email
 from membersdatabase
 where memberid not in
   (select memberid from deregisteredmembers) 

1 个答案:

答案 0 :(得分:0)

从membersdatabase模型中,编写以下查询:

$options = array(
        'conditions' => array('deregisteredmembers.memberid is null'),
        'joins' => array(
            array(
                'alias' => 'deregisteredmembers',  
                'table' => 'deregisteredmembers',
                'type' => 'LEFT',
                'conditions' => array(
                    'deregisteredmembers.memberid = membersdatabase.id',
                ),
            )
        ),
        'fields' => array('membersdatabase.email')
    );

$this->find('all',$options);

您将获得所需的结果