Publiczna aplikacja fdmtech.pl: renderer CMS, formularz audytu, szablony i logotypy

This commit is contained in:
FDMTech
2026-10-09 15:22:48 +02:00
commit 48b544c6b3
32 changed files with 1914 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
<?php
declare(strict_types=1);
namespace FDMTech;
use PDO;
final class Database
{
public static function connect(Config $config): PDO
{
$dsn = $config->get('CMS_DSN');
if (!str_starts_with($dsn, 'mysql:') && !str_starts_with($dsn, 'sqlite:')) {
throw new \RuntimeException('Dedicated CMS DSN required');
}
$options = [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_TIMEOUT => 5];
if (str_starts_with($dsn, 'mysql:') && $config->get('CMS_DB_SSL_CA') !== '') {
$options[PDO::MYSQL_ATTR_SSL_CA] = $config->get('CMS_DB_SSL_CA');
$options[PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT] = true;
}
return new PDO($dsn, $config->get('CMS_DB_USER'), $config->get('CMS_DB_PASSWORD'), $options);
}
}