Search code examples
phpcodeignitercodeigniter-2codeigniter-3

i want rows with different category id using codeigniter


i passed employee id and category id to this function. this employee posted some requirements for some users under severval category. and employees posted for same users with same category multiple times.so i want that repeated ones as single record.anybody knows,please help

     public function get_data_print($id,$cat_id) {

              $this->db->from('jil_requirementbrief');
                $this->db->where('jil_requirementbrief.rqm_managedby', $id);
                  $this->db->where('jil_requirementbrief.rqm_category', $cat_id);

                $query = $this->db->get();
$this->db->from('jil_users'); 
       $this->db->where('jil_users.usr_id',$row->rqm_customerid);
          $query2= $this->db->get()->row_object();
          $row->users_name = $query2->usr_name;
           $row->users_comp = $query2->usr_company;
}

Solution

  • use group_by to avoid duplication

    $this->db->group_by('column_name');
    

    Or you can try distict

    $this->db->distinct();