Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class conexion {
- protected $servidor;
- protected $usuario;
- protected $password;
- protected $database;
- public $mysqli;
- public function __construct() {
- $this->servidor = 'localhost';
- $this->usuario = 'root';
- $this->password = '';
- $this->database = 'db';
- }
- public function conectar() {
- $this->mysqli = new mysqli($this->servidor, $this->usuario, $this->password, $this->database);
- if (mysqli_connect_errno()) {
- echo 'Error en base de datos: '. mysqli_connect_error();
- exit();
- }
- $this->mysqli->query("SET NAMES 'utf8'");
- $this->mysqli->query("SET CHARACTER SET utf8");
- }
- public function desconectar() {
- mysqli_close($this->mysqli);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement