Find Condition by And doen't work + cakephp

前端 未结 2 673
暖寄归人
暖寄归人 2021-01-29 06:15

This function is working on OR condition. I need this to work with AND condition. Any help:

$ands = array();
foreach ($array_training_id as $id) {
        $ands[         


        
2条回答
  •  北恋
    北恋 (楼主)
    2021-01-29 06:42

    The easiest approach would be, to create a habtm-relation.

    Then you can do:

    $users = $this->User->Training->find('all', array('conditions' => array('User.id =' => $ids)));
    

    This finds all where User.id = $id

    With your AND-condition, it would be:

     $users = $this->User->Training->find('all', array('conditions' => 
    'AND' => array('User.id =' => $ids['n'], 'User.id =' => $ids['n'])
    ));
    

提交回复
热议问题