返回用户的cakephp中的所有结果

时间:2011-10-07 12:25:50

标签: cakephp cakephp-1.3

我的模型中有以下代码。我希望展示个人和专业。但目前我的下面的代码不起作用,因为我刚添加一个加号来获得两者。我个人能够展示个人或专业人士。如何更改以下代码以显示个人和专业的所有结果?

function getAll($in_id){
             $this->PassionsUser->id = $in_id;
    return $this->PassionsUser->find('all', array(
                'conditions' => array(
                    'PassionsUser.user_id' => $in_id,
                    'PassionsUser.type' => 'personal'
                )
            )); +   $this->PassionsUser->id = $in_id;
    return $this->PassionsUser->find('all', array(
                'conditions' => array(
                    'PassionsUser.user_id' => $in_id,
                    'PassionsUser.type' => 'professional'
                )


  ));
}

1 个答案:

答案 0 :(得分:0)

这应该有效:

function getAll($id){
    return $this->PassionsUser->find('all', 
    array(
        'conditions' => array(
        'PassionsUser.user_id' => $id,
        'PassionsUser.type' => array('personal', 'professional')
        )
    )
    );  
}

否则,请参阅here

中的cake的OR功能