ajout de setup_server_debian.sh
This commit is contained in:
26
local/share/ytdll/lib/Database.php
Normal file
26
local/share/ytdll/lib/Database.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
class Database {
|
||||
private $pdo;
|
||||
|
||||
public function __construct($config) {
|
||||
$dsn = "pgsql:host={$config['host']};dbname={$config['dbname']}";
|
||||
try {
|
||||
$this->pdo = new PDO($dsn, $config['user'], $config['password'], [
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
|
||||
]);
|
||||
} catch (PDOException $e) {
|
||||
die('Connection failed: ' . $e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function getDefaultSchema() {
|
||||
$query = "SELECT current_schema()";
|
||||
$stmt = $this->pdo->query($query);
|
||||
return $stmt->fetchColumn();
|
||||
}
|
||||
|
||||
public function getPDO() {
|
||||
return $this->pdo;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user