<?php

class Conexion {
    protected $conexion_db;
	protected $conexion_error;
	protected $conexion_mensaje;
	protected $DB_HOST = "localhost";
	protected $DB_USUARIO = "root";
	protected $DB_CONTRA = "1234";
	protected $DB_NOMBRE = "disxii_d";
	protected $DB_CHARSET = "utf8";
    public function __construct()
    {
        try
        {
            $this->conexion_db = new PDO('mysql:host=' . $this->DB_HOST .
										'; dbname=' . $this->DB_NOMBRE
										, $this->DB_USUARIO, $this->DB_CONTRA);
			
            $this->conexion_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
			
			if($this->conexion_db->errorCode() != 0){
				$this->conexion_error = $this->conexion_db->errorCode();
				$mensaje = $this->conexion_mensaje = $this->conexion_db->errorInfo();
				$this->conexion_mensaje = $mensaje[2];
				return $this->conexion_db;
			}
			
            $this->conexion_db->exec("SET CHARACTER SET utf8");
			
            return $this->conexion_db;

        } catch (Exception $e) {
			$this->conexion_error = -1;
			$this->conexion_mensaje = $e->getMessage();
        }
    }
}
