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
精彩评论