Files
fraxle 862f631beb 5.5
New big and small scope sunset and sunrise simulation
New calculations for the day tabs
Added missing icons to simple view
New record popups
Week ahead description popups
Camping profile
Tweak to some of the indoor tems
2026-10-08 09:53:41 +01:00

28 lines
1.1 KiB
PHP

<?php
// ─── SunScope — Database connection ──────────────────────────────────────
// One shared PDO connection, MySQL/MariaDB via XAMPP locally. Credentials
// live in secrets.local.php alongside the Stripe key, never committed.
function db(): PDO {
static $pdo = null;
if ($pdo !== null) return $pdo;
$pdo = new PDO(
'mysql:host=' . DB_HOST . ';dbname=' . DB_NAME . ';charset=utf8mb4',
DB_USER,
DB_PASS,
[
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
// rowCount() on an UPDATE reports rows *matched*, not rows
// changed. journal-save.php leans on that to tell "not yours /
// no such row" apart from "saved, but nothing actually
// differed" - without it, re-saving an entry you didn't edit
// comes back as "Entry not found."
PDO::MYSQL_ATTR_FOUND_ROWS => true,
]
);
return $pdo;
}