Guest User

Untitled

a guest
May 22nd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.76 KB | None | 0 0
  1. class TabelaDAO extends PDOConnectionFactory {
  2.     // irá receber uma conexão
  3.     public $conex = null;
  4.     // constructor
  5.     public function TabelaDAO(){
  6.         $this->conex = PDOConnectionFactory::getConnection();
  7.     }
  8.  
  9.     public function getCamposByIdTabela($id, $inicio, $fim, $order){
  10.         try{
  11.             if(!$order){
  12.                 $order = 'campos';
  13.             }
  14.             $limit = $this->getLimitSql($inicio,$fim);
  15.            
  16.             $stmt = $this->conex->query("SELECT Campos
  17.             FROM tabela1 a, tabela2 b where a.id_tabela = b.id_tabela and b.id_tabela = $id order by $order $limit");
  18.            
  19.             $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
  20.             // desconecta
  21.             $this->conex = null;
  22.  
  23.             // retorna o resultado da query
  24.             return($result);
  25.         }catch ( PDOException $ex ){  echo "Erro: ".$ex->getMessage(); }
  26.     }
  27. }
Add Comment
Please, Sign In to add comment