Skip to content

Instantly share code, notes, and snippets.

@og-shawn-crigger
Forked from rsmarshall/content.php
Created May 15, 2012 14:09
Show Gist options
  • Save og-shawn-crigger/2702049 to your computer and use it in GitHub Desktop.
Save og-shawn-crigger/2702049 to your computer and use it in GitHub Desktop.
search method
public function search()
{
Console::log($this->input->get_post('search_feeds'));
$data = array(
'search_feeds' => $this->input->get_post('search_feeds')
);
Console::log($data);
$this->form_validation->set_data($data);
$this->form_validation->set_rules('search_feeds', 'Search', 'required');
$results = NULL;
if ($this->form_validation->run($this) !== FALSE)
{
$this->suppliers_model->set_table(FALSE);
// Pagination
$offset = $this->input->get('per_page');
$this->pager['base_url'] = current_url().'?search_feeds='. $this->input->get_post('search_feeds') .'&';
$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 ' => '%'.$this->input->get_post('search_feeds').'%'));
// Check your last query in phpmyadmin or whatever you use
Console::log($this->db->last_query() );
$this->suppliers_model->set_table();
}
Template::set('results', $results);
Template::set('search_string', $this->input->get_post('search_feeds'));
Template::set('toolbar_title', 'Search Feeds');
Template::set_view('/content/search');
Template::render();
}
@og-shawn-crigger
Copy link
Author

Added some logging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment