Files
aowow/setup/tools/clisetup/sql.func.php
Sarjuuk a937fb7ac6 Setup/Sounds
* updated sql update for changed generator
Setup/Updates
 * do not throw an invalid scripts supplied - error if no actual scripts where suppied
   (in case of update it is skipped, in every other case it generates everything anyway)
2017-03-22 15:19:10 +01:00

57 lines
1.6 KiB
PHP

<?php
if (!defined('AOWOW_REVISION'))
die('illegal access');
if (!CLI)
die('not in cli mode');
/************************************************/
/* Create content from world tables / dbc files */
/************************************************/
function sql($syncMe = null)
{
require_once 'setup/tools/sqlGen.class.php';
SqlGen::init($syncMe !== null ? SqlGen::MODE_UPDATE : SqlGen::MODE_NORMAL, $syncMe ?: []);
$done = [];
if (SqlGen::$subScripts)
{
$allOk = true;
// start file generation
CLISetup::log('begin generation of '. implode(', ', SqlGen::$subScripts));
CLISetup::log();
foreach (SqlGen::$subScripts as $tbl)
{
$syncIds = []; // todo: fetch what exactly must be regenerated
$ok = SqlGen::generate($tbl, $syncIds);
if (!$ok)
$allOk = false;
else
$done[] = $tbl;
CLISetup::log(' - subscript \''.$tbl.'\' returned '.($ok ? 'sucessfully' : 'with errors'), $ok ? CLISetup::LOG_OK : CLISetup::LOG_ERROR);
set_time_limit(SqlGen::$defaultExecTime); // reset to default for the next script
}
// end
CLISetup::log();
if ($allOk)
CLISetup::log('successfully finished sql generation', CLISetup::LOG_OK);
else
CLISetup::log('finished sql generation with errors', CLISetup::LOG_ERROR);
}
else if ($syncMe)
CLISetup::log('no valid script names supplied', CLISetup::LOG_ERROR);
return $done;
}
?>