Reestructuración de clases y directorios

This commit is contained in:
Fernando Méndez
2021-04-08 09:20:02 +02:00
committed by GitHub
parent 93bbd2a900
commit 54b0907f04
3 changed files with 450 additions and 0 deletions

36
assets/php/dao.php Normal file
View File

@ -0,0 +1,36 @@
<?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:
}
?>