-
Notifications
You must be signed in to change notification settings - Fork 0
/
mysql.php
43 lines (31 loc) · 1 KB
/
mysql.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
require_once ('configuracion.php');
abstract class Mysql{
protected $datos = array();
public function __construct( $datos ) {
foreach ( $datos as $clave => $valor )
if ( array_key_exists( $clave, $this->datos ) )
$this->datos[$clave] = $valor;
}
public function devolverValor( $campo ) {
if ( array_key_exists( $campo, $this->datos ) ) {
return $this->datos[$campo];
}
else
die( "Campo no encontrado" );
}
protected static function connect(){
try{
$conexion = new PDO( DB_DSN, DB_USUARIO, DB_CONTRASENIA );
$conexion->setAttribute( PDO::ATTR_PERSISTENT, true );
$conexion->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
} catch ( PDOException $e ) {
die( "Conexión fallida: " . $e->getMessage() );
}
return $conexion;
}
protected static function desconect($conexion){
$conexion = "";
}
}
?>