2013-04-05 74 views
0

这是我的代码笨加入模型

public function get_news($NewsId= FALSE) 
{ 
    if ($NewsId === FALSE) 
    { 
    $query = $this->db->get('news'); 
    return $query->result_array(); 
    $config['per_page']; $this->uri->segment(3); 
    } 
    $query = $this->db->get_where('news', 
          array('NewsId' => $NewsId, 
            'Language' => '2'); 
    return $query->row_array(); 
} 

的多重条件本不工作,如果我删除语言条件,因此工作在高达码我想 多加一个条件像 目前是NEWID => $ NewSID的,我想在这里这段代码LanId = $ LanId提前

方面多加一个

回答

2
$this-db->where(field1,condition1); 
$this-db->where(field2,condition2); 
$this-db->where(field3,condition3); 
$this->db->get(table); 

你可以设置多达你想要的

有文字上没有区别。但既然你坚持,

$this->db->get_where('table', 
    array('field1'=>'condition1', 
      'field2'=>'condition2', 
      'field3'=>'condition3') 
); 
+0

它是正确的,但在一个查询,在我当前的查询,会请我目前的阵列不会改变我的查询上加一个条件只需添加更多的一个conditioin – rafiq 2013-04-05 08:37:13

+0

没有区别。这是一天结束时的查询生成器。没有理由为什么你可以使用'get_where'而不是'where' – 2013-04-05 08:38:25

+0

只是我写我的模型,如果我使用$ this-> db_where那么这将是我的项目的其他地方的问题,所以我不必改变布局只需添加条件 – rafiq 2013-04-05 08:42:30