connect_error) { die("Verbindung fehlgeschlagen: " . $conn->connect_error); } // 1. Abfrage: Alle Dateien, deren Pfad '%files/archive/%' enthält $sql1 = "SELECT fc.fileid, fc.name AS file_name, fc.path AS file_path, fc.size, fc.mimetype FROM oc_filecache AS fc WHERE fc.path LIKE '%files/archive/%' ORDER BY fc.name DESC"; $result1 = $conn->query($sql1); // 2. Abfrage: Alle Mimetypes und ihre IDs $sql2 = "SELECT id, mimetype FROM oc_mimetypes"; $result2 = $conn->query($sql2); // 3. Abfrage: Alle Tags im System $sql3 = "SELECT id, name FROM oc_systemtag"; $result3 = $conn->query($sql3); // 4. Abfrage: Verknüpfung zwischen Files und Tags (mit 'files' statt 'file') $sql4 = "SELECT objectid, systemtagid FROM oc_systemtag_object_mapping WHERE objecttype = 'files'"; $result4 = $conn->query($sql4); // Alle Mimetypes in einem Array speichern $mimetypes = []; while ($row = $result2->fetch_assoc()) { $mimetypes[$row['id']] = $row['mimetype']; } // Alle Tags in einem Array speichern $tags = []; while ($row = $result3->fetch_assoc()) { $tags[$row['id']] = $row['name']; } // Tags mit Dateiinformationen verbinden $fileTags = []; while ($row = $result4->fetch_assoc()) { $fileTags[$row['objectid']][] = $tags[$row['systemtagid']]; } // Füge den Tag "archive" zu jedem Eintrag in fileTags hinzu // foreach ($fileTags as $fileId => $existingTags) { // // Prüfen, ob der Tag "archive" bereits vorhanden ist // if (!in_array('archive', $existingTags)) { // // Füge den Tag "archive" hinzu (nur im Array, nicht in der DB) // $fileTags[$fileId][] = 'archive'; // } // }