<?php

/**
 * Created by PhpStorm.
 * User: elporfirio
 * Date: 20/08/16
 * Time: 11:25 AM
 */
class Conexion
{

    #Datos para conexión
    private $domain = "localhost";
    private $database = "munimazamarigob_mesadepartes";
    private $user = "root";
    private $password = "";

    private $conexion = null;

    public function Conectar(){
        #Conectarse a la base de datos
        try {
            $this->conexion = new PDO(
                'mysql:host=' . $this->domain . ';dbname=' . $this->database .';port=3306',
                $this->user,
                $this->password,
                array(
                    PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8",
                    PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)
            );
        } catch (PDOException $ex){
            echo "<strong>Error de Conexión: </strong>" . $ex->getMessage() . "<br>";
            die();
        }
    }

    public function getConexion(){
        if($this->conexion == null){
            $this->Conectar();
        }
        return $this->conexion;
    }
}