beginTransaction(); $stmt = $pdo->prepare("INSERT INTO besitz_status (spieler_id, spiel_id, status) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE status = VALUES(status)"); $stmt->execute([$spieler_id, $spiel_id, $status]); $stmtChildren = $pdo->prepare("SELECT id FROM spiele WHERE parent_id = ?"); $stmtChildren->execute([$spiel_id]); $children = $stmtChildren->fetchAll(); if ($children) { $stmtChildStatus = $pdo->prepare("INSERT INTO besitz_status (spieler_id, spiel_id, status) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE status = VALUES(status)"); foreach ($children as $child) { $stmtChildStatus->execute([$spieler_id, $child['id'], $status]); } } $pdo->commit(); $msg = "Status aktualisiert!"; } catch (Exception $e) { $pdo->rollBack(); $msg = "Fehler: " . $e->getMessage(); } } // --- DATEN LADEN --- $spieler = $pdo->query("SELECT * FROM spieler ORDER BY name ASC")->fetchAll(); $sqlSpiele = "SELECT s.*, r.name as reihe_name, t.bezeichnung as typ_name FROM spiele s LEFT JOIN game_reihe r ON s.game_reihe_id = r.id LEFT JOIN game_typ t ON s.game_typ_id = t.id ORDER BY r.name ASC, s.titel ASC"; $alleSpieleRaw = $pdo->query($sqlSpiele)->fetchAll(); $statusMapping = []; $statusData = $pdo->query("SELECT spieler_id, spiel_id, status FROM besitz_status")->fetchAll(); foreach ($statusData as $row) { $statusMapping[$row['spiel_id']][$row['spieler_id']] = $row['status']; } // --- HIERARCHIE AUFBAUEN --- $spieleBaum = []; $childrenMap = []; foreach ($alleSpieleRaw as $s) { if ($s['parent_id']) { $childrenMap[$s['parent_id']][] = $s; } else { $reihe = $s['reihe_name'] ?: 'Sonstige'; $spieleBaum[$reihe][] = $s; } } // Hilfsfunktion fΓΌr Bild-URL function getImgPath($url) { if (empty($url)) return 'https://via.placeholder.com/150x150?text=Kein+Bild'; return (strpos($url, 'http') === 0) ? $url : IMG_URL . $url; } ?> EXIT - Bestand & Besitz

πŸ“¦ Bestand & Besitz

Dashboard
$hauptSpiele): ?>
Spiel / Abenteuer
πŸ“
Cover
Cover