Advertisement
prezman

Untitled

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