Welcome Guest, Not a member yet? Register   Sign In
extending a simple search
#1

[eluser]snowstar[/eluser]
Hi All,

I've been using a simple search on my site for awhile now how-ever i would like to extend it to help limit some of the search results i get back from my queries.

I search via first name, lastname or address to get my results currently. My DB has now gotten much larger so i would like to implement multiple word search so i can search by first name, lastname and address for a more define search.

My current controller

Code:
class Search extends Controller {
        
    function index()
    {
        
        $data = array();
        $this->load->model('search_model');
        
        $search_data = $this->input->post('search');
        
        if($query = $this->search_model->getSearchResults($search_data))
        {
            $data['records'] = $query;
        }
        
        $this->load->view('includes/header.php');
        $this->load->view('search_results', $data);
        $this->load->view('includes/footer.php');
        
    }
}

my current model

Code:
class Search_model extends Model {

    function Search_model()
    {
        parent::Model();
    }

    function getSearchResults ($searchdata)
    {
        $this->db->like('firstname', $searchdata);
        $this->db->or_like('lastname', $searchdata);
        $this->db->or_like('addressA1', $searchdata);
        $this->db->or_like('addressA2', $searchdata);
        $this->db->or_like('addressB1', $searchdata);
        $this->db->or_like('addressB2', $searchdata);
        $this->db->orderby('firstname');
        $query = $this->db->get('clients');
        return $query->result();
    }

}

I've searched around and found a post which best matches what i want http://ellislab.com/forums/viewthread/113868/

how-ever he doesn't actually post how he sorted it. Any help with pointing me in the right direction is much appreciated.

Thanks


Messages In This Thread
extending a simple search - by El Forum - 12-05-2010, 04:12 PM
extending a simple search - by El Forum - 12-06-2010, 02:11 AM
extending a simple search - by El Forum - 12-06-2010, 02:35 AM
extending a simple search - by El Forum - 12-06-2010, 03:12 AM



Theme © iAndrew 2016 - Forum software by © MyBB