Welcome Guest, Not a member yet? Register   Sign In
Profiler shows two queries when only one was executed?

Hey guys,

Please help me with the following:

CI profiler shows two queries when only one being executed

The query code:

public function search_user_profile($first_name, $last_name, $work, $school, $place_grewup, $place_last_met, $country_of_birth) {
        $this->db->select('work, school, place_grewup, place_last_met, country_of_birth');
        $this->db->select('first_name, last_name');
        $this->db->where('user.id = search_query.user_id');

         if ($first_name!=''){
          $this->db->like('first_name', $first_name); }
          if ($last_name!=''){
          $this->db->like('last_name', $last_name); }
        if ($work!=''){
          $this->db->like('work', $work);}
          if ($school!=''){
          $this->db->like('school', $school); }
           if ($place_grewup!=''){
           $this->db->like('place_grewup', $place_grewup); }
            if ($place_last_met!=''){
            $this->db->like('place_last_met', $place_last_met); }
             if ($country_of_birth!=''){
             $this->db->like('country_of_birth', $country_of_birth); }

        $query = $this->db->get();

           if($query->num_rows() >0) {
               foreach($query->result() as $row)
                  $data[]=$row;      //assign each row from database to $data[] array
               return $data;  //this function returns $data[] array which has all the $rows from




Any input is appreciated!

Can you please share the profiler output as well?

If that's the case, you must be running the same query twice. If you do a file search for <your_model>->search_user_profile, you'll be able to spot where it's being called, and check your application flow. I suspect you're calling it twice without realising it. If you're still stuck, please post your controller code.

Thanks guys!

I've tracked the issue down:

You are right, I was running two queries at the same time by calling the same function twice : )

Theme © iAndrew 2016 - Forum software by © MyBB