From 8d767e61e815e3ec24c0783780a7c8c6457847d7 Mon Sep 17 00:00:00 2001 From: "v.rodriguezcamacho" Date: Thu, 24 Sep 2026 09:30:38 +0200 Subject: [PATCH] carpeta includes con conexionBD.php --- includes/conexionBD.php | 29 +++++++++++++++++++++++++++++ index.php | 1 + 2 files changed, 30 insertions(+) create mode 100644 includes/conexionBD.php diff --git a/includes/conexionBD.php b/includes/conexionBD.php new file mode 100644 index 0000000..0d4636c --- /dev/null +++ b/includes/conexionBD.php @@ -0,0 +1,29 @@ + PDO::ERRMODE_EXCEPTION, + PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, + PDO::ATTR_EMULATE_PREPARES => false, + ]; + + return new PDO($dsn, $usuario, $pass, $opciones); + + } catch (PDOException $error) { + return [ + 'error' => 'No se pudo conectar a la base de datos.', + 'error_tecnico' => $error->getMessage() + ]; + } +} +?> \ No newline at end of file diff --git a/index.php b/index.php index a47b9e7..ee8d7dc 100644 --- a/index.php +++ b/index.php @@ -1,3 +1,4 @@ +