Files
inventario/config/conection.php
T
Alfredo Lima 9f2001c549 Inicio
2020-02-26 15:43:19 -06:00

38 lines
880 B
PHP
Executable File

<?php
class Conexion{
private static $conexion;
public static function abrirConexion(){
if(!isset(self::$conexion)){
try {
include_once 'config.bd.php';
self::$conexion = new PDO($DB, $userName, $Password);
self::$conexion ->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
self::$conexion -> exec('SET CHARACTER SET utf8');
} catch (PDOException $e) {
echo 'Falló la conexión: ' . $e->getMessage();
die();
}
}
}
public static function cerrarConexion(){
if(isset(self::$conexion)){
self::$conexion = null;
}
}
public static function obtenerConexion(){
return self::$conexion;
}
}
?>