简体   繁体   English

PHP分页限制

[英]PHP Pagination Limit

In my controller I have the following code: 在我的控制器中,我有以下代码:

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');
}

In my model I these codes: 在我的模型中我这些代码:

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;
}

The object get_limit is suppose to output a query that starts the query depends on what page the user is on: get_limit对象假设输出一个启动查询的查询取决于用户所在的页面:

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

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

However, when I echo $query, I get the following: 但是,当我回显$ query时,我得到以下内容:

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

So for some reason, the _perPage constant doesn't output. 因此,由于某种原因,_perPage常量不会输出。 I'm new to OOP so any pointers would be appreciated. 我是OOP的新手所以任何指针都会受到赞赏。

You are using wrong naming for construct:- 您使用错误的命名构造: -

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

It should be 它应该是

public function __construct($perPage, $instance){

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM