PDO::ERRMODE_EXCEPTION] ); $sql = file_get_contents(__DIR__ . '/../data/migration.sql'); $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()) . '