SW/assets/php/dao.php
Fernando Méndez 7e2ef23349
Añadida LOGIN a través de BASE DE DATOS
Se ha creado la base de datos de usuarios y toda la lógica para iniciar sesión mediante ella.
2021-04-07 19:56:06 +02:00

36 lines
976 B
PHP
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
// TO-DO: Completar
class DAO {
//Constants:
private const _SERVERNAME = "localhost";
private const _USERNAME = "sw";
private const _PASSWORD = "_admin_";
//private const _BD = "complucine";
//Atributes:
public $mysqli;
//Constructor:
public function __construct($bd_name){
try{
if (!$this->mysqli) {
$this->mysqli = new mysqli(self::_SERVERNAME, self::_USERNAME,
self::_PASSWORD, $bd_name);
}
// echo "Conexión a la BD, satisfactoria.";
} catch (Exception $e){
echo "Error de conexión a la BD: ". mysqli_connect_error();
exit();
}
/* ... */
}
//Destructor:
public function __destruct(){
$this->mysqli->close();
}
//Methods:
}
?>