Optimize way of making query in codeigniter
01:56 10 Oct 2013

I am working on a project in codeigniter. I am facing problem in making query on the basis of multiple condition. The simplest way is to make seperate condition for each property, but I need an optimized way cause I will have more than 25 properties later on, so 25 conditions look weired. Here is sample code

$this->db->select('*');
$this->db->from('listings');
$this->db->join('hotel_features','listings.id = hotel_features.listing_id');
$this->db->where('listings.country_code',$country_t);
$this->db->like('listings.city',$city_t);


    if($room_features_ids != '')
    {
        $room_features_array[0] = "extra_beds";
        $room_features_array[1] = "satellite_tv";
        $room_features_array[2] = "airconditioning";
        $room_features_array[3] = "cable_tv_service";
        $room_features_array[4] = "bathroom";
        $room_features_array[5] = "phone";
        $room_features_array[6] = "wifi";
        $room_features_array[7] = "kitchen";
        $room_features_array[8] = "desk";
        $room_features_array[9] = "refrigerator";   

        $room_features_ids = explode("-",$room_features_ids);

                    // if $room_features_array has 0,1,2 this means first 3 features are available in hotel.
        foreach($room_features_ids as $ids)
        {
            if($room_features_array[$ids] == 'extra_beds')
            {
                $this->db->where('hotel_features.extra_beds',1);    
            }
            else if($room_features_array[$ids] == 'satellite_tv')
            {
                $this->db->where('hotel_features.satellite_tv',1);  
            }
            //and so on.... for all properties
        }
    }

Now my question is that, Is there any optimize way to do it? Something like

        foreach($room_features_ids as $ids)
        {
            $this->db->where('hotel_features.'.$room_features_array[$ids],1);   
        }

Or any other way? Thanks in advance

php mysql codeigniter