add all files

This commit is contained in:
Rucus
2026-02-17 09:29:34 -06:00
parent b8c8d67c67
commit 782d203799
21925 changed files with 2433086 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
<?php // phpcs:ignoreFile
/**
* Create a PDO connection to the archive SQL Server instance that hosts dbo.id_names.
*
* @throws \RuntimeException When the required PDO sqlsrv driver is unavailable.
*/
function archive_db_connect(): \PDO
{
if (!class_exists(\PDO::class)) {
throw new \RuntimeException('PDO is required to connect to the archive database.');
}
if (!in_array('sqlsrv', \PDO::getAvailableDrivers(), true)) {
throw new \RuntimeException('The sqlsrv PDO driver is not available. Enable it to query the archive database.');
}
static $cachedConnection = null;
if ($cachedConnection instanceof \PDO) {
return $cachedConnection;
}
$server = getenv('ARCHIVE_DB_SERVER') ?: '192.168.0.13\SQLEXPRESS';
$database = getenv('ARCHIVE_DB_NAME') ?: 'history';
$username = getenv('ARCHIVE_DB_USER') ?: 'opce';
$password = getenv('ARCHIVE_DB_PASSWORD') ?: 'opcelasuca';
$dsn = sprintf('sqlsrv:Server=%s;Database=%s;LoginTimeout=5', $server, $database);
$cachedConnection = new \PDO(
$dsn,
$username,
$password,
[
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
\PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC,
]
);
return $cachedConnection;
}