import Meteorschauers fertig
This commit is contained in:
@@ -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";
|
||||
}
|
||||
Reference in New Issue
Block a user