Código PHP:
class database
{
public function __construct()
{
$this->MySQLi['hostname'] = 'localhost';
$this->MySQLi['username'] = '';
$this->MySQLi['password'] = '';
$this->MySQLi['database'] = 'db';
$this->Connection = mysqli_connect($this->MySQLi['hostname'], $this->MySQLi['username'], $this->MySQLi['password'], $this->MySQLi['database']);
if(!$this->Connection)
{
die('Error de conexion: ' . mysqli_connect_error());
}
}
public function query($sql)
{
$this->Query = $this->Connection->query($sql);
return $this->Query;
//Liberar la memoria de la consulta
$this->Query->free();
}
public function close()
{
$this->Connection->close();
}
}