Takes in a file, process it and output a new file with additional columns.
This commit is contained in:
Stefan Lazic
2026-07-10 15:45:02 +01:00
parent 2f387a4c1c
commit a451060c1b
876 changed files with 169373 additions and 0 deletions
+47
View File
@@ -0,0 +1,47 @@
<?php
declare(strict_types=1);
namespace App;
use PDO;
final class Database
{
private PDO $pdo;
public function __construct(PDO $pdo)
{
$this->pdo = $pdo;
}
public static function fromConfig(array $config): self
{
$database = $config['database'] ?? [];
$host = (string) ($database['host'] ?? '127.0.0.1');
$port = (string) ($database['port'] ?? '5432');
$name = (string) ($database['name'] ?? 'spreadsheet_importer');
$user = (string) ($database['user'] ?? 'postgres');
$password = (string) ($database['password'] ?? '');
$sslMode = (string) ($database['sslmode'] ?? 'prefer');
$pdo = new PDO(
sprintf('pgsql:host=%s;port=%s;dbname=%s;sslmode=%s', $host, $port, $name, $sslMode),
$user,
$password,
[
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
]
);
return new self($pdo);
}
public function pdo(): PDO
{
return $this->pdo;
}
}