php class Connection private mysqli public function __construct this-

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
<?php
class Connection {
private $mysqli;
public function __construct() {
$this->mysqli = new mysqli("localhost", "Имя пользователя", "Пароль", "База данных");
$this->mysqli->query("SET lc_time_names = 'ru_RU'");
$this->mysqli->query("SET NAMES 'utf8'");
}
public function query($query){
return $this->mysqli->query($query);
}
public function __destruct() {
if ($this->mysqli) $this->mysqli->close();
}
}
?>