PDO::ERRMODE_EXCEPTION] ); $sqlPath = DB_TYPE === 'pgsql' ? __DIR__ . '/../py_service/sql/schema_postgresql.sql' : __DIR__ . '/../data/migration.sql'; $sql = file_get_contents($sqlPath); $statements = array_filter(array_map('trim', explode(';', $sql))); $created = 0; $inserted = 0; $errors = 0; foreach ($statements as $query) { if ($query === '' || strpos($query, '--') === 0) continue; try { $pdo->exec($query); if (stripos($query, 'CREATE') !== false) $created++; if (stripos($query, 'INSERT') !== false) $inserted++; } catch (\Throwable $e) { $errors++; } } echo '
База данных ' . htmlspecialchars(DB_NAME) . ' обновлена.
'; echo '' . htmlspecialchars($e->getMessage()) . '