Conexion class defined in php/conexion.php. All PHP files that need database access instantiate this class and call obtenerConexion() to receive a PDO connection object.
The Conexion Class
Configuration Fields
| Property | Description |
|---|---|
$host | The database server address. For local development this is typically "localhost". |
$db_name | The name of the MySQL database. Must match the database created when importing the SQL file. |
$username | The MySQL user that has access to the database. |
$password | The MySQL user’s password. Often empty for local development setups. |
Error Handling
obtenerConexion() sets PDO::ATTR_ERRMODE to PDO::ERRMODE_EXCEPTION. This means any failed query or connection problem will throw a PDOException rather than silently returning false, making errors visible and easier to debug.
The method also runs set names utf8 immediately after connecting, ensuring special characters (accents, ñ, etc.) are handled correctly throughout the application.
The database name must be
hotel_guevarini_publico — this is the name that base_de_datos.sql creates automatically when imported. If you use a different name here, the connection will fail.Configuration Steps
Open php/conexion.php
Locate the file at
php/conexion.php in the project root and open it in your editor.Set the host
Replace
"tu-host" with your database server address. For XAMPP, WAMP, or Laragon running locally, use "localhost".Example: XAMPP Local Setup
For a standard XAMPP installation the default MySQL user isroot with an empty password: