<?php

class Database
{
   //LOCAL
   private $hostname = "localhost", 
    $database = "hamburguesas",
    $username = 'root', 
    $password = "", $charset = 'utf8';

//    //DESPLEGAOD 000WEBHOST
//     private $hostname = "localhost", 
//     $database = "id21227067_electrobike",
//     $username = 'id21227067_team_electrobike', 
//     $password = "Electrobike123*", $charset = 'utf8';

    function conectar()
    {
        try {
            $conexion = "mysql:host=" . $this->hostname . ";dbname=" . $this->database .
                ";charset=" . $this->charset;
            $options = [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_EMULATE_PREPARES => false,];

            $pdo = new PDO($conexion, $this->username, $this->password, $options);

            return $pdo;
        } catch (PDOException $e) {
            echo 'Error de conexion' . $e->getMessage();
            exit;
        }
    }
}
