Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.98 KB | None | 0 0
  1. <?
  2.  
  3.     public function getDataTable()
  4.     {
  5.         $this->load->library('Datatables');
  6.        
  7.         $this->filtroListItens('datatables');
  8.  
  9.         $this->datatables
  10.             ->select('id, nome, email')
  11.             ->from('tabela');
  12.  
  13.         return $this->datatables2->generate();
  14.     }
  15.  
  16.     public function getDados()
  17.     {
  18.         $this->filtroListItens('db');
  19.  
  20.         $query = $this->db
  21.             ->select('id, nome, email')
  22.             ->from('tabela');
  23.             ->get();
  24.  
  25.         if ($query->num_rows() > 0) {
  26.             return $query->result();
  27.         }
  28.  
  29.         return array();
  30.     }
  31.  
  32.     protected function filtroListItens($lib = 'db')
  33.     {
  34.         $busca = $this->input->post('busca');
  35.         $tipo  = $this->input->post('tipo');
  36.  
  37.         if ($busca && $busca != '') {
  38.             $this->$lib->where('busca', $busca);
  39.         }
  40.  
  41.         if ($tipo && $tipo != '') {
  42.             $this->$lib->where('tipo', $tipo);
  43.         }
  44.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement