jcarloslb

Dúvida

Jul 8th, 2014
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.17 KB | None | 0 0
  1. //Model
  2. function get_search($search_terms = 'default'){
  3.        
  4.     $this->db->like('numero', $search_terms['numero']);
  5.     $this->db->like('id_categoria', $search_terms['id_categoria']);
  6.     $this->db->like('mes', $search_terms['mes']);
  7.     $this->db->like('ano', $search_terms['ano']);
  8.     $this->db->like('vereadores', $search_terms['vereadores']);
  9.     $this->db->like('assunto', $search_terms['assunto']);
  10.        
  11.     $query = $this->db->get('leis');
  12.        
  13.         if ($query->num_rows() > 0)
  14.         {
  15.             return $query->result_array();
  16.         }
  17.         else
  18.         {
  19.             return false;
  20.         }
  21.        
  22. }
  23.  
  24.  
  25. //Controller
  26. function buscar(){
  27.            
  28.     $search_terms = array(
  29.       'numero' => $this->input->post('numero'),
  30.       'id_categoria' => $this->input->post('id_categoria'),
  31.       'mes' => $this->input->post('mes'),
  32.       'ano' => $this->input->post('ano'),
  33.       'vereadores' => $this->input->post('vereadores'),
  34.       'assunto' => $this->input->post('assunto')
  35.     );
  36.            
  37.     $data['query'] = $this->leis_model->get_search($search_terms);
  38.     $data['categorias'] = $this->leis_categorias_model->get_leis_categorias();
  39.            
  40.     $this->template->load('template','leis/resultados_view.php', $data);
  41. }
Advertisement
Add Comment
Please, Sign In to add comment