Cakephp 按描述进行分页和排序

Cakephp 按描述进行分页和排序,cakephp,cakephp-2.5,Cakephp,Cakephp 2.5,现在我用下面的查询查询我的数据库,它工作得很好,它与另一个表连接 $tapplicant = $this->Tapplicant->find( 'all', array( 'fields' => array( 'Tapplicant.*', 'Toutcome.*' ), 'order' => array('Tapplicant.AppDate' =>

现在我用下面的查询查询我的数据库,它工作得很好,它与另一个表连接

 $tapplicant = $this->Tapplicant->find(
    'all',
    array(
        'fields' => array(
            'Tapplicant.*',
            'Toutcome.*'

        ),
         'order' => array('Tapplicant.AppDate' => 'DESC'),
        'joins' => array(
            array(
                'table' => 'toutcome',
                'alias' => 'Toutcome',
                'type' => 'INNER',
                'conditions' => array('Tapplicant.AppID = Toutcome.AppID' )


            )
        ),
        'limit' => 15
    )
);
我已设置寻呼机:

 public $paginate = array (
'order' => array('Tapplicant.AppID' => 'desc'),
'limit' => 15,

);
我需要知道的是我如何:

添加分页器 在当前日期使用CURDATE
我不知道在哪里添加它。

您可以在“查找”中正确执行此操作:

$tapplicant = $this->Tapplicant->find(
    'all',
    array(
        'fields' => array(
            'Tapplicant.*',
            'Toutcome.*'

        ),
        'joins' => array(
            array(
                'table' => 'toutcome',
                'alias' => 'Toutcome',
                'type' => 'INNER',
                'conditions' => array('Tapplicant.AppID = Toutcome.AppID' )


            )
        ),
        'limit' => 15,
        'order' => array('Tapplicant.AppID' => 'desc'),
    )
);
'conditions' => array('Tapplicant.created' => date('Y-m-d')),
让paginate这样:

public $paginate = array('limit' => 15);
如果您只想要当天的帖子,只需将其添加到查找中:

$tapplicant = $this->Tapplicant->find(
    'all',
    array(
        'fields' => array(
            'Tapplicant.*',
            'Toutcome.*'

        ),
        'joins' => array(
            array(
                'table' => 'toutcome',
                'alias' => 'Toutcome',
                'type' => 'INNER',
                'conditions' => array('Tapplicant.AppID = Toutcome.AppID' )


            )
        ),
        'limit' => 15,
        'order' => array('Tapplicant.AppID' => 'desc'),
    )
);
'conditions' => array('Tapplicant.created' => date('Y-m-d')),
在控制器中:-

$this->paginate = array(
    'fields' => array(
        'Tapplicant.*',
        'Toutcome.*'
    ),
    'joins' => array(
        array(
            'table' => 'toutcome',
            'alias' => 'Toutcome',
            'type' => 'INNER',
            'conditions' => array('Tapplicant.AppID = Toutcome.AppID' )


        )
    ),
    'conditions' => array(
        'Tapplicant.AppDate' => date('Y-m-d')
    ),
    'order' => array('Tapplicant.AppDate' => 'DESC'),
    'limit' => 15
);

$this->set('tapplicant', $this->paginate());

你想用CURDATE做什么?结果只能是今天的日期@drmonkeynijai仍然需要添加:$this->set'tapplicant',$tapplicant;当我在索引页上显示结果时,使用@drmonkeyninja@MaxPayneUK很抱歉,忘记包含该步骤。我已经相应地更新了答案-我只需将“Tapplicant.AppDate”=>日期“Y-m-d”与“Tapplicant.AppDate>=”=>日期“Y-m-d”进行调整,效果非常好,谢谢!