开发者

Returning all the results in cakephp of a user

开发者 https://www.devze.com 2023-04-11 05:09 出处:网络
I have the following codes in my model. I wish to display both personal and professional. But currently my below codes isnt working as I just added a plus sign to get both. Individually I am able to d

I have the following codes in my model. I wish to display both personal and professional. But currently my below codes isnt working as I just added a plus sign to get both. Individually I am able to display both personal OR professional. How can I change the code below to display all results for both personal and professional?

function getAll($in_id){
      开发者_如何学JAVA       $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'
                )


  ));
}


This should work:

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

Otherwise, see cake's OR capabilities in here

0

精彩评论

暂无评论...
验证码 换一张
取 消