2015-05-03 30 views
0

如何通過偏移和在下面的查詢perpage計數如何通過偏移量和per_page變量笨的方式連接查詢

 $this->db->select('*');  
     $this->db->from($this->table1); 
     $this->db->join($this->table2, 'plot.location_id = locations.location_id'); 
     $this->db->join($this->table3, 'plot.plot_type = plot_types.plot_id'); 
     $this->db->join($this->table4, 'plot.user_id = admin.id'); 


     $query = $this->db->get(); 
     return $query->result(); 
+0

這個問題已經回答和接受了,但我不明白你的代碼有什麼問題,它似乎沒問題。 –

回答

1
$this->db->limit(); 

可以限制你想通過返回的行數查詢

+0

最好閱讀文檔,例如https://ellislab.com/codeigniter/user-guide/database/active_record.html 我是一個壞故事講述者:) – splash58

0

是的,我試圖用限制..它的工作原理感謝

下面是代碼

 $this->db->select('*');  
     $this->db->from($this->table1); 
     $this->db->join($this->table2, 'plot.location_id = locations.location_id'); 
     $this->db->join($this->table3, 'plot.plot_type = plot_types.plot_id'); 
     $this->db->join($this->table4, 'plot.user_id = admin.id'); 
     $this->db->order_by($this->table1.'.plot_id','DESC'); 
     $this->db->limit($per_page, $offset); 
     $query = $this->db->get(); 
     return $query->result();