import Meteorschauers fertig

This commit is contained in:
2026-04-03 18:40:59 +02:00
parent b2462f6512
commit 5d5901c623
7 changed files with 425 additions and 1130 deletions
+11
View File
@@ -0,0 +1,11 @@
<?php
$config = require getcwd() . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'database.php';
$dsn = sprintf('mysql:host=%s;dbname=%s;charset=%s', $config['host'], $config['dbname'], $config['charset'] ?? 'utf8mb4');
try {
$pdo = new PDO($dsn, $config['user'], $config['pass'], [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);
echo "CONNECTED\n";
$stmt = $pdo->query('SHOW TABLES LIKE "meteorshowers"');
var_export($stmt->fetchColumn()); echo "\n";
} catch (Throwable $e) {
echo get_class($e) . ': ' . $e->getMessage() . "\n";
}
+20
View File
@@ -0,0 +1,20 @@
<?php
$config = require getcwd() . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'database.php';
$dsn = sprintf('mysql:host=%s;dbname=%s;charset=%s', $config['host'], $config['dbname'], $config['charset'] ?? 'utf8mb4');
$sql = <<<'SQL'
CREATE TABLE IF NOT EXISTS `meteorshowers` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`shower_code` varchar(16) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `uq_meteorshowers_code` (`shower_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
SQL;
try {
$pdo = new PDO($dsn, $config['user'], $config['pass'], [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);
$pdo->exec($sql);
echo "CREATE_OK\n";
$stmt = $pdo->query('SHOW TABLES LIKE "meteorshowers"');
var_export($stmt->fetchColumn()); echo "\n";
} catch (Throwable $e) {
echo get_class($e) . ': ' . $e->getMessage() . "\n";
}
File diff suppressed because it is too large Load Diff
+9
View File
@@ -0,0 +1,9 @@
<?php
$_SERVER['REQUEST_METHOD'] = 'POST';
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
$_SERVER['SERVER_NAME'] = 'localhost';
$_POST['json_path'] = getcwd() . DIRECTORY_SEPARATOR . 'scripts' . DIRECTORY_SEPARATOR . 'import' . DIRECTORY_SEPARATOR . 'MeteorShowers.json';
ob_start();
require getcwd() . DIRECTORY_SEPARATOR . 'scripts' . DIRECTORY_SEPARATOR . 'import' . DIRECTORY_SEPARATOR . 'import_meteorshowers.php';
$output = ob_get_clean();
echo $output;
+6
View File
@@ -0,0 +1,6 @@
<?php
$config = require getcwd() . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'database.php';
$dsn = sprintf('mysql:host=%s;dbname=%s;charset=%s', $config['host'], $config['dbname'], $config['charset'] ?? 'utf8mb4');
$pdo = new PDO($dsn, $config['user'], $config['pass'], [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC]);
$cols = $pdo->query('SHOW COLUMNS FROM `meteorshowers`')->fetchAll(PDO::FETCH_COLUMN);
echo implode(",", $cols), "\n";