通过ids查找所有专辑+查找所有非私人如何?

时间:2011-08-08 13:16:22

标签: cakephp

我使用以下网址id搜索所有相册:

$this->Album->find('all', array(
    'conditions' => array(
        'Album.id' => $albums_ids,
        'Album.galleries_id' => $id
    )
));

但我也希望找到所有非私人相册(private == 0以及。我试过了:

$this->Album->find('all', array(
    'conditions' => array(
        'Album.id' => $albums_ids,
        'Album.galleries_id' => $id,
        'OR'=> array(
            array('Album.private' => 0),
            array('Album.galleries_id' => $id)
        )
    )
));

但没有成功......

2 个答案:

答案 0 :(得分:1)

它应该是gallery_id

$this->Album->find('all', array(
'conditions' => array(
    'Album.galleries_id' => $id,
    'OR'=> array(
        'Album.private' => 0,
        'Album.id' => $albums_ids
    )
)
     

));

答案 1 :(得分:0)

您是否只是简单地寻找以下逻辑?

$this->Album->find('all', array(
    'conditions' => array(
        'Album.id' => $albums_ids,
        'Album.galleries_id' => $id,
        'Album.private' => 0,
    )
));