Advertisement
Guest User

Untitled

a guest
Nov 6th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.02 KB | None | 0 0
  1. <?php
  2.  
  3.     class conexaoClass {
  4.         var $conn;
  5.        
  6.         function abrir_conexao() {
  7.             $servername = 'localhost';
  8.             $username = 'root';
  9.             $password = '';
  10.             $dbname = 'test';
  11.  
  12.             $this -> conn = new mysqli($servername, $username, $password, $dbname);
  13.         }
  14.            
  15.         function getconn() {
  16.             return $this -> conn;
  17.         }
  18.     }
  19.  
  20.     $Oconn = new conexaoClass();
  21.     $Oconn -> abrir_conexao();
  22.     $conn = $Oconn -> getconn();  
  23.    
  24.  
  25.     $NOME = "Macarana";
  26.    
  27.     //$sql = "SELECT * FROM tabela_teste ORDER by TES_ID";
  28.     //$sql = "INSERT INTO tabela_teste (TES_NOME, TES_EMAIL, TES_TELEFONE) VALUES ('".$NOME."', 'teste2', 'teste3')";
  29.     //$sql = "UPDATE tabela_teste SET TES_NOME='".$NOME."' WHERE TES_TELEFONE = 3";
  30.     //$sql = "DELETE FROM tabela_teste WHERE TES_TELEFONE = 3";
  31.    
  32.     $sql = "SELECT * FROM tabela_teste WHERE TES_ID > 9";
  33.     $result = $conn->query($sql);
  34.     while($linha = $result->fetch_assoc()) {
  35.         echo $linha["TES_NOME"]."<br>";
  36.     }
  37.  
  38.  
  39.  
  40.  
  41. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement