SIMON Master Console Rebuild
True command center for SIMON + WEB360
This rebuild gives you a cleaner production spine: interactive tree, live viewer, guarded editor, dynamic graphics, architecture map, and note storage. It is designed to sit beside your existing
console.php
and become the stronger replacement path.
Dashboard
Tree
Viewer
System Map
File Registry
Notes
Files
15,025
Folders
377
Scanned Size
3.79 GB
PHP Files
791
Editable Text Files
12,309
File viewer
guarded to /htdocs
/simon/core/database.php
<?php declare(strict_types=1); final class SimonDatabase { private static ?PDO $pdo = null; private static ?string $error = null; public static function connection(): ?PDO { if (self::$pdo instanceof PDO) return self::$pdo; if (SIMON_DB_DSN === '') { self::$error = 'Database DSN is not configured.'; return null; } try { self::$pdo = new PDO(SIMON_DB_DSN, SIMON_DB_USER, SIMON_DB_PASSWORD, [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_TIMEOUT => 12, ]); return self::$pdo; } catch (Throwable $e) { self::$error = $e->getMessage(); return null; } } public static function error(): ?string { return self::$error; } public static function tableExists(string $table): bool { $pdo = self::connection(); if (!$pdo) return false; $s = $pdo->prepare('SELECT COUNT(*) FROM information_schema.tables WHERE table_schema=DATABASE() AND table_name=?'); $s->execute([$table]); return (int)$s->fetchColumn() > 0; } public static function scalar(string $sql, array $params = [], mixed $fallback = null): mixed { $pdo = self::connection(); if (!$pdo) return $fallback; try { $s=$pdo->prepare($sql); $s->execute($params); $v=$s->fetchColumn(); return $v===false?$fallback:$v; } catch (Throwable) { return $fallback; } } public static function rows(string $sql, array $params = []): array { $pdo = self::connection(); if (!$pdo) return []; try { $s=$pdo->prepare($sql); $s->execute($params); return $s->fetchAll(); } catch (Throwable) { return []; } } public static function health(): array { $pdo=self::connection(); if (!$pdo) return ['ok'=>false,'database'=>null,'version'=>null,'error'=>self::$error]; try { return ['ok'=>true,'database'=>(string)$pdo->query('SELECT DATABASE()')->fetchColumn(),'version'=>(string)$pdo->query('SELECT VERSION()')->fetchColumn(),'error'=>null]; } catch (Throwable $e) { return ['ok'=>false,'database'=>null,'version'=>null,'error'=>$e->getMessage()]; } } }
Save file
Quick jump
open a path
Open