Files
aowow/setup/tools/sqlgen/events.func.php
Sarjuuk 59f58f8506 Setup
* automatically set and unset maintenance mode when data is being edited (either sql or files)
 * added more verbose help prompts. They should now always appear when -h is used.
 * added --setup as more intuitive command for --firstrun. --firstrun is now considered deprecated and will be removed in due time.
 * unfuck order of indizes in --siteconfig
 * fixed some typos
 * convert echo use to CLI::write
 * move scattered command line argument checks to CLISetup
2020-12-30 00:29:30 +01:00

50 lines
1.3 KiB
PHP

<?php
if (!defined('AOWOW_REVISION'))
die('illegal access');
if (!CLI)
die('not in cli mode');
SqlGen::register(new class extends SetupScript
{
protected $command = 'events';
protected $tblDependencyTC = ['game_event', 'game_event_prerequisite'];
public function generate(array $ids = []) : bool
{
$eventQuery = '
SELECT
ge.eventEntry,
holiday,
0, -- cuFlags
IFNULL(UNIX_TIMESTAMP(start_time), 0),
IFNULL(UNIX_TIMESTAMP(end_time), 0),
occurence * 60,
length * 60,
IF (gep.eventEntry IS NOT NULL, GROUP_CONCAT(prerequisite_event SEPARATOR " "), NULL),
description
FROM
game_event ge
LEFT JOIN
game_event_prerequisite gep ON gep.eventEntry = ge.eventEntry
{
WHERE
ge.eventEntry IN (?a)
}
GROUP BY
ge.eventEntry';
$events = DB::World()->select($eventQuery, $ids ?: DBSIMPLE_SKIP);
foreach ($events as $e)
DB::Aowow()->query('REPLACE INTO ?_events VALUES (?a)', array_values($e));
return true;
}
});
?>