Codeigniter select query with AND and OR condition

后端 未结 7 994
情话喂你
情话喂你 2020-12-04 01:55

I want a Codeigniter select query from a table with three conditions in .

1. wrk_fld_exc = 140
2. wrk_cs_sts = Open
3. wrk_dlvrd_sts = Delivered OR wrk_cl_st         


        
7条回答
  •  忘掉有多难
    2020-12-04 02:14

        $this->db->select("*");
        $this->db->from("table_name");
        if($condition1 != ''){
            $this->db->where('wrk_fld_exc', 140);
        }
        if($condition2 != ''){
            $this->db->where('wrk_cs_sts ', open);
        }
        //You can limit the results
        $this->db->limit(5);
        $q = $this->db->get();
        return $q->result();
    

    This is the basic structure of the query you can implement in this way in codeigniter. You can add conditions if you require.

提交回复
热议问题