2013-09-25 96 views
0

在我的控制,我有以下代碼: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"; 
} 

但是,當我回顯$查詢時,我得到以下內容:

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的新手,所以任何指針將不勝感激。

回答

2

您正在使用錯誤的命名爲結構: -

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

應該

public function __construct($perPage, $instance){ 
+0

OMG ......太感謝你了。那真是一個愚蠢的錯誤。 – user2773365

+0

嗨,很高興幫助你:) – Roopendra