webservice/bin/buildLog.php

58 lines
1.6 KiB
PHP
Raw Normal View History

2017-02-22 15:03:56 +01:00
<?php
2017-02-28 12:26:29 +01:00
require_once __DIR__ . '/../application/bin.bootstrap.php';
2017-02-22 15:03:56 +01:00
// --- Options
$displayUsage = false;
try {
$opts = new Zend_Console_Getopt(array(
'help|?' => "Aide.",
'log' => "",
));
$opts->parse();
2017-02-28 12:26:29 +01:00
$optionsNb = count($opts->getOptions());
2017-02-22 15:03:56 +01:00
} catch (Zend_Console_Getopt_Exception $e) {
$displayUsage = true;
}
// --- Aide / Options
2017-02-28 12:26:29 +01:00
if ($optionsNb == 0 || isset($opts->help)) {
2017-02-22 15:03:56 +01:00
$displayUsage = true;
}
// --- Usage
if ($displayUsage) {
echo "\nLog\n\n";
echo $opts->getUsageMessage();
exit;
}
if ($opts->log) {
$sql = "SELECT * FROM sdv1.logs_item";
$stmt = $conn->prepare($sql);
$stmt->execute();
2017-04-10 17:11:03 +02:00
$outPath = APPLICATION_PATH . '/../vendor/scores/library/src/Scores/Account/Log/List.php';
2017-02-22 15:03:56 +01:00
$outFile = $outPath . '/Config.php';
if ($stmt->rowCount() > 0) {
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
file_put_contents($outFile, "<?php\n");
file_put_contents($outFile, "/* Auto generated ".date('Y-m-d H:i:s')." */\n");
file_put_contents($outFile, "return array(\n", FILE_APPEND);
foreach ($result as $c) {
file_put_contents($outFile, "\t'". $c->Code . "' => array(,\n", FILE_APPEND);
file_put_contents($outFile, "\t\t'Label' => ". $c->Label . ",\n", FILE_APPEND);
file_put_contents($outFile, "\t\'Description' => ". $c->Description . ",\n", FILE_APPEND);
file_put_contents($outFile, "\t\t'Category' => ". $c->Category . ",\n", FILE_APPEND);
file_put_contents($outFile, "\t),\n", FILE_APPEND);
}
file_put_contents($outFile, ");\n", FILE_APPEND);
}
}