2016-07-31 68 views
1

我試圖執行select語句,將顯示相關帖子到當前帖子,但排除當前帖子的選擇。選擇背後的前提是,它將從當前帖子的類別中選擇6個帖子,排除任何通過永久鏈接變量的帖子。CodeIgniter get_where()與NOT IN

代碼:

$query = $this->db->get_where('chanl_posts', array('category' => $category), NOT IN array('permalink' => $permalink), 6); 

這正是我試圖無濟於事,和文檔狀態,其中一個get_where_not_in()方法藏漢,但會允許我的類別條款適用於它?

回答

2

嘗試用where_not_in()

$limit = 6; 
$offset = 0; 
$this->db->where('category', $category); 
$this->db->where_not_in('permalink', $permalink); 
$query = $this->db->get('chanl_posts',$limit,$offset);