CakePHP - paginate and sort 2nd level association

后端 未结 2 1447
陌清茗
陌清茗 2021-01-14 18:48

I understand that this has been asked 100,000 times but I\'ve pretty much read all 100,000 replies and none of them seem to match what I\'m after. I\'ve tried every possible

2条回答
  •  不知归路
    2021-01-14 19:18

    Great answer. I used it. To try generalise it for other users :

    $this->FirstLevel->bindModel(array(
        'belongsTo' => array(
            'SecondLevel' => array(
                'foreignKey' => false,
                'conditions' => array('SecondLevel.firstLevel_id = FirstLevel.id')
            ),
        )
    ));
    
    $this->Paginator->settings = array(
        //'conditions' => $retrieveDataCondition,
        'contain' => array('SecondLevel')
    );
    $data = $this->Paginator->paginate('FirstLevel');
    

提交回复
热议问题