Created
May 15, 2012 13:49
-
-
Save rsmarshall/2701926 to your computer and use it in GitHub Desktop.
search method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function search() | |
{ | |
$data = array( | |
'search_string' => $this->input->get_post('search_string') | |
); | |
$this->form_validation->set_data($data); | |
$this->form_validation->set_rules('search_string', 'Search', 'required'); | |
$results = NULL; | |
if ($this->form_validation->run($this) !== FALSE) | |
{ | |
Template::set_message('Validation passed', 'success'); | |
$this->suppliers_model->set_table(FALSE); | |
$search_string = $this->input->get_post('search_string'); | |
// Pagination | |
$offset = $this->input->get('per_page'); | |
$this->pager['base_url'] = current_url().'?search_string='. $search_string; | |
$this->pager['total_rows'] = $this->suppliers_model->count_all(); | |
$this->pager['per_page'] = 1; | |
$this->pager['page_query_string'] = true; | |
$this->load->library('pagination', $this->pager); | |
$results = $this->suppliers_model | |
->limit($this->pager['per_page'], $offset) | |
->find_all_by(array ('supplier_code LIKE ' => '%' . $search_string . '%')); | |
$this->suppliers_model->set_table(); | |
} | |
Template::set('results', $results); | |
Template::set('search_string', $this->input->get_post('search_string')); | |
Template::set('toolbar_title', 'Search Feeds'); | |
Template::set_view('/content/search'); | |
Template::render(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment