PHP分页限制

时间:2013-09-25 06:00:00

标签: php

在我的控制器中,我有以下代码:

if($action=='shipping_list'){ 
    $numrows=inquire_row(); //Get number of rows in query
    $pages= new Paginator('10', 'p'); //create object
    $pages->set_total($numrows);
    $shipping=shipping_list(); //Goes to model
    include('shipping_list.php');
}

在我的模型中我是这些代码:

function shipping_list(){
    global $MEMS;
    global $pages;
        $query = "SELECT * FROM Inventory " .$pages->get_limit()
        ." WHERE Yield >=320 AND (Q = 'Pass' OR Q='No Q') AND shipdate = ' '
        ORDER BY Wafer ASC, RC ASC";
    $shipping = $MEMS -> query($query);
    return $shipping;
}

对象get_limit假设输出一个启动查询的查询取决于用户所在的页面:

public function __contruct($perPage, $instance){
    $this->_instance = $instance;       
$this->_perPage = $perPage; 
}

public function get_limit(){
    return "LIMIT ".$this->get_start().",$this->_perPage";
}

然而,当我回显$ query时,我得到以下内容:

SELECT * FROM Inventory LIMIT 0, WHERE Yield >=320 AND (Q = 'Pass' OR Q='No Q') AND shipdate = ' ' ORDER BY Wafer ASC, RC ASC

因此,由于某种原因,_perPage常量不会输出。我是OOP的新手,所以任何指针都会受到赞赏。

1 个答案:

答案 0 :(得分:2)

您对构造使用了错误的命名: -

 public function __contruct($perPage, $instance){
                      ^

应该是

public function __construct($perPage, $instance){