-1
兩個數據庫的數據進行比較,我想寫在CakePHP中執行以下操作:從CakePHP中
(select email
from membersdatabase
where memberid not in
(select memberid from deregisteredmembers)
兩個數據庫的數據進行比較,我想寫在CakePHP中執行以下操作:從CakePHP中
(select email
from membersdatabase
where memberid not in
(select memberid from deregisteredmembers)
從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);
你會得到期望的結果
這是我需要的。起初我認爲邏輯應該在控制器中實現 – user2032928