codeigniter添加模型的多个条件

时间:2013-04-05 08:17:01

标签: php codeigniter web

这是我的代码

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();
}

如果我删除了语言条件,则无法正常工作 在up代码中我想再添加一个条件 目前是NewId => $ NewsId和我想在此代码中添加一个LanId = $ LanId

提前问候

1 个答案:

答案 0 :(得分: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')
);
相关问题