Advertisement
Guest User

Untitled

a guest
Jul 11th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.92 KB | None | 0 0
  1. <?php
  2. class conexao
  3. {
  4.     private $host;
  5.     private $user;
  6.     private $pass;
  7.     private $banco;
  8.     private $sql;
  9.     private $rs;
  10.    
  11.     function conectar()
  12.     {
  13.     $con = mysql_connect($this->host,$this->user,$this->pass);
  14.     return $con;
  15.     }
  16.    
  17.     function setConectar($host,$user,$conectar)
  18.     {
  19.     $this->host = $host;
  20.     $this->user = $user;
  21.     $this->pass = $pass;   
  22.     }
  23.    
  24.     function sel_Banco()
  25.     {
  26.     $sel = mysql_select_db($this->banco);
  27.     if($sel)
  28.     {
  29.     return TRUE;   
  30.     } else {
  31.     return FALSE;      
  32.     }
  33.     }
  34.    
  35.     function setSel_Banco($banco)
  36.     {
  37.     $this->banco = $banco;
  38.     }
  39.    
  40.     function query()
  41.     {
  42.     $qry = mysql_query($this->sql);
  43.     $this->rs = $qry;
  44.     }
  45.    
  46.     function setQuery($sql)
  47.     {
  48.     $this->sql = $sql; 
  49.     }
  50.    
  51.     function exibir()
  52.     {
  53.     $num = mysql_num_rows($this->rs);
  54.     for($i=0;$i<$num;$i++)
  55.     {
  56.     $ft = mysql_fetch_array($this->rs);
  57.     $id = $ft ['id'];
  58.     $nome = $ft ['nome'];
  59.     echo "$id <br>";
  60.     echo "$nome <hr>";
  61.     }  
  62.     }  
  63. }
  64.  
  65.  
  66. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement