0

I have this connection to connect to a database. This works on Windows, but does not work in Linux.

<?php class conexion{
private static $instance;

/** @var \mysqli */
public $conexion;
private $server;
private $username;
private $password;
private $database;

/**
 * Devuelve la instancia única de esta clase ya conectada.
 * Así no hay que abrir tantas conexiones a la misma base de datos.
 *
 * @return self
 */
public static function getInstance()
{
    if (isset(self::$instance)) {
        return self::$instance;
    } else {
        $temp = new self();
        $temp->conectar();
        return self::$instance = $temp;
    }
}

public function __construct()
{
    $this->server = "localhost";
    $this->username = "root";
    $this->password = "";
    $this->database = "store";
}

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

function conectar()
{
    $this->conexion = new mysqli($this->server, $this->username, $this->password, $this->database);
}

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

function query($sql_cmd)
{
    return $this->conexion->query($sql_cmd);
}
}
Panda
  • 6,955
  • 6
  • 40
  • 55
Luis Osuna
  • 1
  • 1
  • 5

0 Answers0