我们如何在 yii 中为这个查询实现 CActive Record
SELECT *
FROM location WHERE locationid NOT IN
( SELECT location
FROM memberlocation
WHERE memberid = 2371)
我们如何在 yii 中为这个查询实现 CActive Record
SELECT *
FROM location WHERE locationid NOT IN
( SELECT location
FROM memberlocation
WHERE memberid = 2371)
尝试这个
$sql='SELECT *
FROM location WHERE locationid NOT IN
( SELECT location
FROM memberlocation
WHERE memberid = 2371)';
$result = Yii::app()->db->createCommand($sql)->queryAll();
或者你可以做这样的事情
$result= Location::model()->findAll(array(
'select'=>'*',
'condition'=>'locationid NOT IN( SELECT location
FROM memberlocation
WHERE memberid = :member_id)',
'params'=>array(':member_id'=2371)
));