1 | <?php |
2 | |
3 | require_once __DIR__ . "/bdCrea.php"; |
4 | |
5 | class Bd |
6 | { |
7 | |
8 | private static ?PDO $conexion = null; |
9 | |
10 | static function getConexion(): PDO |
11 | { |
12 | if (self::$conexion === null) { |
13 | |
14 | self::$conexion = new PDO( |
15 | // cadena de conexión |
16 | "sqlite:srvbd.db", |
17 | // usuario |
18 | null, |
19 | // contraseña |
20 | null, |
21 | // Opciones: conexiones persistentes y lanza excepciones. |
22 | [PDO::ATTR_PERSISTENT => true, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION] |
23 | ); |
24 | |
25 | bdCrea(self::$conexion); |
26 | } |
27 | |
28 | return self::$conexion; |
29 | } |
30 | } |
31 |