(.*?)<\/h1>/i", $html, $m)) { return strip_tags($m[1]); } return null; } function insertOrUpdate($slug, $label) { global $pdo; $stmt = $pdo->prepare("SELECT id FROM nav_items WHERE url = ?"); $stmt->execute([$slug]); if ($stmt->fetch()) { $pdo->prepare("UPDATE nav_items SET label = ? WHERE url = ?") ->execute([$label, $slug]); return "Updated '$slug' with label '$label'"; } else { $pdo->prepare("INSERT INTO nav_items (label, url, icon_class, parent_id, sort_order) VALUES (?, ?, NULL, NULL, 0)") ->execute([$label, $slug]); return "Inserted '$slug' → '$label'"; } } $folders = scanFolders(__DIR__); foreach ($folders as $folder) { $slug = basename($folder); $h1 = extractH1("$folder/index.php") ?? ucfirst(str_replace('-', ' ', $slug)); echo insertOrUpdate($slug, $h1) . "
"; } ?>

How to Cite This Article

APA

Allen, J. J. S. (2025). Sync Pages To Db. Pattern Field Theory. https://www.patternfieldtheory.com/articles/sync-pages-to-db/

MLA

Allen, James Johan Sebastian. "Sync Pages To Db." Pattern Field Theory, 2025, https://www.patternfieldtheory.com/articles/sync-pages-to-db/.

Chicago

Allen, James Johan Sebastian. "Sync Pages To Db." Pattern Field Theory. November 3, 2025. https://www.patternfieldtheory.com/articles/sync-pages-to-db/.

BibTeX

@article{allen2025pft,
  author  = {James Johan Sebastian Allen},
  title   = {Sync Pages To Db},
  journal = {Pattern Field Theory},
  year    = {2025},
  url     = {https://www.patternfieldtheory.com/articles/sync-pages-to-db/}
}