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

[eluser]Jay Logan[/eluser]
I have a database full of customers that get assigned to different locations around country. One of my location managers will log in and see a list of his customers, no problem. But I want to give them the ability to search there their filtered list of customers and I just can't seem to get the where_in & like function to work together. Here is what I have so far.

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);

            }

        }
                
        $this->db->like('name_first', $this->input->post('keywords'));
        //$this->db->or_like('name_last', $this->input->post('keywords'));
        //$this->db->or_like('email_home', $this->input->post('keywords'));

        
        $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;
    }


This will let me find customers of a location if i enter the first name. But when I uncomment the or_like function it starts searching the entire database. Any help?


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