Inicio
This commit is contained in:
Executable
+38
@@ -0,0 +1,38 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user