Kod
<?php
class Database{
private $connection;
/**************************/
/* Konstruktor klasy */
/**************************/
function __construct($host, $user, $pass, $name){
if(@!$this->connection = new mysqli($host, $user, $pass, $name)){
throw new Exception("Nie udało się połączyć z sewerem ".$this->connection->error, $this->connection->errno);
}
}
}
$host="localhosts";
$user="test";
$pass="test1";
$name="test";
$connection = new Database($host, $user, $pass, $name);
?>
class Database{
private $connection;
/**************************/
/* Konstruktor klasy */
/**************************/
function __construct($host, $user, $pass, $name){
if(@!$this->connection = new mysqli($host, $user, $pass, $name)){
throw new Exception("Nie udało się połączyć z sewerem ".$this->connection->error, $this->connection->errno);
}
}
}
$host="localhosts";
$user="test";
$pass="test1";
$name="test";
$connection = new Database($host, $user, $pass, $name);
?>