Advertisement
Guest User

Untitled

a guest
Jul 3rd, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. <?php
  2.  
  3. class Conexion {
  4. private $mysql;
  5. private $bdName;
  6. private $user;
  7. private $pass;
  8.  
  9. public function __construct($bdName){
  10. $this->bdName = $bdName;
  11. $this->user = "root";
  12. $this->pass = "";
  13. }
  14.  
  15. public function conectar(){
  16. $this->mysql = new mysqli(
  17. "localhost",
  18. $this->user,
  19. $this->pass,
  20. $this->bdName
  21. );
  22. if (mysqli_connect_errno()) {
  23. printf("Error de conexión: %s\n", mysqli_connect_error());
  24. exit();
  25. }
  26. }
  27.  
  28. public function ejecutar($query){
  29. return $this->mysql->query($query);
  30. }
  31.  
  32. public function desconectar(){
  33. $this->mysql->close();
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement