cakePHP - 限制在最后添加一个随机100

时间:2013-06-11 21:56:52

标签: cakephp limit

我只想将我的行限制为400,但它会使用'400,100'创建查询并导致问题。

这是我的代码:

$this->paginate = array('limit' => 400,
                        'order' => array('MantisBugTable.sort_order' => 'ASC'),
                        'group' => '`MantisBugTable`.`id`',
                        'joins' => array(
                                      array(
                                        'alias' => 'MantisLastReadTicketTable',
                                        'table' => 'mantis_last_read_ticket_table',
                                        'type' => 'LEFT',
                                        'conditions' => array('`MantisLastReadTicketTable`.`ticket_id` = `MantisBugTable`.`id`', '`MantisLastReadTicketTable`.`user_id` = '.$userAdminInfo['UserAdmin']['id'])
                                      ),
                                      array(
                                        'alias' => 'MantisBugnoteTable',
                                        'table' => 'mantis_bugnote_table',
                                        'type' => 'LEFT',
                                        'conditions' => '`MantisBugnoteTable`.`bug_id` = `MantisBugTable`.`id`'
                                      )
                                  ),
                       'fields' => array('MantisBugTable.*', 'MantisLastReadTicketTable.*', 'COALESCE(MAX(`MantisBugnoteTable`.`last_modified`), `MantisBugTable`.`last_updated`, NULL) AS MantisBugnoteTable__LastModified')
                      );

但是它最终会出现另一个'100'的限制:

SELECT `MantisBugTable`.*, `MantisLastReadTicketTable`.*, COALESCE(MAX(`MantisBugnoteTable`.`last_modified`), `MantisBugTable`.`last_updated`, NULL) AS MantisBugnoteTable__LastModified FROM `mantis_bug_table` AS `MantisBugTable` LEFT JOIN `mantis_last_read_ticket_table` AS `MantisLastReadTicketTable` ON (`MantisLastReadTicketTable`.`ticket_id` = `MantisBugTable`.`id` AND `MantisLastReadTicketTable`.`user_id` = 101) LEFT JOIN `mantis_bugnote_table` AS `MantisBugnoteTable` ON (`MantisBugnoteTable`.`bug_id` = `MantisBugTable`.`id`)  WHERE `MantisBugTable`.`handler_id` = 0 AND (NOT (`MantisBugTable`.`category_id` IN (10, 12)) AND NOT (`MantisBugTable`.`status` IN (80, 90)))  GROUP BY `MantisBugTable`.`id`  ORDER BY `MantisBugTable`.`sort_order` ASC  LIMIT 400, 100

为什么你认为这种情况正在发生?

我尝试过设置'offset'=> 0但是没有用。

谢谢, 安迪

1 个答案:

答案 0 :(得分:-3)

没关系,不知怎的,我的饼干越过了。