Php 带有和/或查询的codeigniter模型函数

Php 带有和/或查询的codeigniter模型函数,php,codeigniter,Php,Codeigniter,我在模型中有这个函数 function select($table,$match,$or){ $this->db->select('*'); $this->db->from($table); $this->db->where($match)->or_where($or); $query = $this->db->get(); $query_result = $q

我在模型中有这个函数

 function select($table,$match,$or){
        $this->db->select('*');
        $this->db->from($table);
        $this->db->where($match)->or_where($or);
        $query = $this->db->get();
        $query_result = $query->result();
        return $query_result;
    }
和在控制器中

$post = array("class"=>"XI","section"=>"A","stream"=>"Medical");
$data = $this->main_model->select("class_subjects",array("class"=>$post['class'],"section"=>"all","stream"=>$post['stream']),$post);
            print_r($data);
我没有得到任何错误,但这是打印整个数据表。如何匹配
class='XI'和stream='Medical'以及(section='A'或section='all')
试试这个

function select($table,$match,$or)
{
    $query = $this->db
        ->select("*")
        ->from($table)
        ->group_start()
            ->where($match)
        ->group_end()
        ->group_start()
            ->or_where($or)
        ->group_end()
        ->get();

    $strSql = $this->db->last_query();

    return $query->result();
}
如果这不起作用-打印出$strSql变量并在此处发布查询