Guest User

Untitled

a guest
Jan 4th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. <?php
  2.  
  3. class db{
  4.  
  5. private $dbServer = "localhost";
  6. private $dbUser = "root";
  7. private $dbPassword = "";
  8. private $dbName = "sql_queries";
  9. private $conn;
  10.  
  11. public function __construct(){
  12. $this->conn = mysqli_connect($this->dbServer, $this->dbUser, $this->dbPassword) or die("Não foi possível estabelecer a conexão com a base de dados! ".mysqli_error($this->conn));
  13. $this->conn = mysqli_select_db($this->conn, $this->dbName) or die("Não foi possível se conectar com o banco de dados! ".mysqli_error($this->conn));
  14.  
  15. $this->setQuery();
  16. }
  17.  
  18. public function getConn(){
  19. return $this->conn;
  20. }
  21.  
  22. public function setQuery(){
  23.  
  24. $sql = "CREATE TABLE IF NOT EXISTS sql_queries.aluno(
  25. aluno_id INT NOT NULL AUTO_INCREMENT,
  26. nome_aluno varchar(255),
  27. dataNascimento_aluno date,
  28. nome_pai varchar(255),
  29. nome_mae varchar(255),
  30. RG_aluno char(10),
  31. cpf_aluno char(11),
  32. telefone_aluno (10)
  33. celular_aluno char(13),
  34. CONSTRAINT PK_aluno PRIMARY KEY (aluno_id);
  35. );";
  36.  
  37. $result = mysqli_query($this->conn, $sql);
  38. }
  39. }
Add Comment
Please, Sign In to add comment