36 lines
1.0 KiB
PHP
36 lines
1.0 KiB
PHP
<?php
|
||
// Используем для подключения к базе данных MySQL
|
||
class Database
|
||
{
|
||
// Учётные данные базы данных
|
||
# private $host = "10.10.1.246";
|
||
# public $db_name = "tsd_users";
|
||
#private $username = "tsd";
|
||
##private $password = "gcIL6UrWFtSdDTbz";
|
||
private $host = "10.10.0.20";
|
||
public $db_name = "tsd";
|
||
private $username = "tsd_user";
|
||
private $password = "stptoamh";
|
||
|
||
|
||
|
||
|
||
|
||
public $conn;
|
||
|
||
// Получаем соединение с базой данных
|
||
public function getConnection()
|
||
{
|
||
$this->conn = null;
|
||
|
||
try {
|
||
$this->conn = new PDO("pgsql:host=".$this->host.";port=5432;dbname=".$this->db_name, $this->username, $this->password);
|
||
//$this->conn = new PDO("mysql:host=" . $this->host . ";dbname=" . $this->db_name.";charset=UTF8", $this->username, $this->password);
|
||
} catch (PDOException $exception) {
|
||
echo "Ошибка соединения с БД: " . $exception->getMessage();
|
||
}
|
||
|
||
return $this->conn;
|
||
}
|
||
}
|