Misc fixes and improvements
* Added request logging to com.noccy.apiclient * Added plugin com.noccy.watcher * Added pipe command and filter support * Fixes and stubs
This commit is contained in:
@ -28,10 +28,20 @@ class PdoQueryCommand extends Command {
|
||||
$stmt = $sourcePdo->query($query);
|
||||
$stmt->execute();
|
||||
|
||||
$csv = $input->getOption("csv");
|
||||
|
||||
$table = new Table($output);
|
||||
$table->setStyle($box?"box":"compact");
|
||||
$hasColumns = false;
|
||||
while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||
if ($csv) {
|
||||
$output->writeln(
|
||||
join(",", array_map(function($v) {
|
||||
return str_contains(',',$v) ? var_export($v,true) : $v;
|
||||
}, $row))
|
||||
);
|
||||
continue;
|
||||
}
|
||||
if (!$hasColumns) {
|
||||
if ($vert) {
|
||||
$table->setHeaders([ "Field", "VarType", "Value" ]);
|
||||
@ -76,6 +86,7 @@ class PdoQueryCommand extends Command {
|
||||
$this->setName("pdo:query");
|
||||
$this->setDescription("Run a query against a defined PDO connection");
|
||||
$this->addOption("res", "r", InputOption::VALUE_REQUIRED, "Resource to query", "db");
|
||||
$this->addOption("csv",null, InputOption::VALUE_NONE, "Output as CSV");
|
||||
$this->addOption("vertical", "l", InputOption::VALUE_NONE, "Print result as rows instead of columns");
|
||||
$this->addOption("box", null, InputOption::VALUE_NONE, "Use boxed table");
|
||||
$this->addOption("unserialize", "u", InputOption::VALUE_NONE, "Attempt to unserialize serialized data");
|
||||
|
Reference in New Issue
Block a user