Adds login/logout/session handling, a create-critter form backed by adjectives/nouns/verbs/locations lookup tables, Replicate-generated critter images saved to disk, and a Tailwind-styled critter gallery on the homepage. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
21 lines
562 B
PHP
21 lines
562 B
PHP
<?php
|
|
function getDbConnection(): PDO
|
|
{
|
|
static $pdo = null;
|
|
|
|
if ($pdo === null) {
|
|
$dbPath = __DIR__ . '/../app.sqlite';
|
|
$pdo = new PDO('sqlite:' . $dbPath);
|
|
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
$pdo->exec('PRAGMA foreign_keys = ON');
|
|
$pdo->exec('CREATE TABLE IF NOT EXISTS users (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
username TEXT NOT NULL UNIQUE,
|
|
email TEXT NOT NULL UNIQUE,
|
|
password TEXT NOT NULL
|
|
)');
|
|
}
|
|
|
|
return $pdo;
|
|
}
|