Welcome Guest, Not a member yet? Register   Sign In
Need Help With Active Record For Search Function
#8

[eluser]Jay Logan[/eluser]
Ahhhhhhhh. Thanks so much. This is really going to help me with a lot of new features I'm working on. Here is the final function.

Code:
function search($locations = FALSE)
    {
        $this->db->select('JL_customers.*, JL_customers_status.name as status_name, JL_customers_status.color as status_color');
        $this->db->from('JL_customers');
        
        if ($locations) {

            foreach ($locations as $location) {

                $this->db->or_where('assn_location_id', $location);

            }

        }
        
        $keywords = $this->input->post('keywords');
        $where = "(`name_first`  LIKE '".$keywords."' OR  `name_last`  LIKE '".$keywords."' OR  `email_home`  LIKE '".$keywords."')";
        $this->db->where($where, NULL, FALSE);
        $this->db->order_by('date_last_modified', 'desc');
        $this->db->join('JL_customers_status', 'JL_customers_status.id = JL_customers.status', 'left');
        $get_results = $this->db->get();
        $results = $get_results->result_array();
        return $results;
        
    }


Messages In This Thread
Need Help With Active Record For Search Function - by El Forum - 01-26-2010, 02:50 PM
Need Help With Active Record For Search Function - by El Forum - 01-27-2010, 06:06 AM
Need Help With Active Record For Search Function - by El Forum - 01-27-2010, 08:10 AM
Need Help With Active Record For Search Function - by El Forum - 01-27-2010, 08:27 AM
Need Help With Active Record For Search Function - by El Forum - 01-28-2010, 07:09 AM
Need Help With Active Record For Search Function - by El Forum - 01-28-2010, 07:15 AM
Need Help With Active Record For Search Function - by El Forum - 01-28-2010, 07:21 AM
Need Help With Active Record For Search Function - by El Forum - 01-28-2010, 07:42 AM
Need Help With Active Record For Search Function - by El Forum - 01-28-2010, 07:57 AM



Theme © iAndrew 2016 - Forum software by © MyBB