在我的控制器中,我有以下代码:
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 的新手,所以任何指针都将不胜感激。