In cakephp how can I do a find with conditions on a related field?

前端 未结 4 1617
独厮守ぢ
独厮守ぢ 2020-12-18 15:33

I\'ve got a model (Listings) that has and belongs to a few different models, I\'d like to find all of this model where it\'s related model (Openhouses) have a condition. The

4条回答
  •  一向
    一向 (楼主)
    2020-12-18 16:28

    $this->List->find('all', array(
        'contain' => array(
            'conditions' => array(
                'Openhouse.date >' => $openhouse_start->format('Y-m-d H:i:s'),
                'Openhouse.date <' => $openhouse_end->format('Y-m-d H:i:s')
                                 ),
            'order' => array('Openhouse.date DESC')
                          )
                                 )
    )
    

提交回复
热议问题