2

我的问题是:

在控制器中:

$this->paginate = array('conditions' => array($cond_review),'limit' => 3); $result1 = $this->paginate('Model1');

$this->paginate = array('conditions' => array($condUser),'limit' => 2); $result2 = $this->paginate('Model2');

if($this->Session->read('tab_item') == 'visit'){
            if($this->RequestHandler->isAjax())
                {
                        $this->layout = "";
                        $this->render('/elements/review_detail_visit_ajax');
                        return;
                }
            }else if($this->Session->read('tab_item') == 'review'){

                    if($this->RequestHandler->isAjax())
                        {
                            $this->layout = "";
                            $this->render('/elements/friend_review_listing_ajax');
                            return;
                        }

            }

模型:

function paginate($conditions, $fields, $order, $limit, $page = 1, $recursive = null, $extra = array()) {

     $cod = implode(" AND ", $conditions);
    $recursive = -1;
    //$group = $fields = array('week', 'away_team_id', 'home_team_id');
     return $this->find('all', compact('conditions', 'fields', 'order', 'limit', 'page', 'recursive', 'group'));
}

/**
 * Overridden paginateCount method
 */
function paginateCount($conditions = null, $recursive = 0, $extra = array()) {
    $cod = implode(" AND ", $conditions);
    $sql = "SELECT id FROM table WHERE 1=1 AND ".$cod;
    $this->recursive = $recursive;
    $results = mysql_query($sql);
    $num = mysql_num_rows($results);
    return $num ;
}

这里我的问题是 2 结果数组 $result1 和 $result2 有不同数量的数据。但它总是返回相同数量的页面并且限制也相同。

如何解决这个问题呢?

4

0 回答 0