<?php
class class_mysql
{
    private $conexion;
    private $servername;
    private $username;
    private $password;
    private $dbName;
    private $port;

    public function __construct($servername, $port, $dbName, $username, $password ) {
        $this->servername = $servername;
        $this->username = $username;
        $this->password = $password;
        $this->dbName = $dbName;
        $this->port = $port;

        $this->connect();
    }

    private function connect() {
        try
        {
            $this->conexion = new mysqli($this->servername, $this->username, $this->password, $this->dbName, $this->port);
            $conn = $this->conexion;
            $this->conexion->select_db($this->dbName);
        }
        catch (Exception $err)     
        {
            echo $err;
            /*
        if ($this->conexion->connect_error) {
            die("Conexión fallida33: " . $this->conexion->connect_error);
            */
        }
    }

    public function disconnect() {
        $this->conexion->close();
    }

    public function getConnection() {
        return $this->conexion;
    }

}

    /*
// Configurar el charset
$conn->query("SET NAMES 'utf8'");
$conn->query("SET character_set_server = 'utf8'");
$conn->query("SET character_set_connection = 'utf8'");
$conn->query("SET character_set_results = 'utf8'");
$conn->query("SET character_set_client = 'utf8'");
*/

?>