Added plugins and build tools

This commit is contained in:
2021-12-09 00:58:28 +01:00
parent a0d68a606c
commit eefe53a438
46 changed files with 4049 additions and 1 deletions

View File

@ -0,0 +1,36 @@
<?php
namespace SparkPlug\Com\Noccy\Pdo;
use Spark\Commands\Command;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class PdoExecCommand extends Command {
protected function execute(InputInterface $input, OutputInterface $output)
{
$source = $input->getOption("res");
$sourcePdo = get_resource($source)->getPDO();
if (!$sourcePdo) {
$output->writeln("<error>Invalid resource: {$source}</>");
return Command::INVALID;
}
$query = $input->getArgument('query');
$stmt = $sourcePdo->prepare($query);
$stmt->execute();
return Command::SUCCESS;
}
protected function configure() {
$this->setName("pdo:exec");
$this->setDescription("Run a query without returning data");
$this->addOption("res", "r", InputOption::VALUE_REQUIRED, "Resource to query", "db");
$this->addArgument("query", InputArgument::REQUIRED, "SQL query to execute");
}
}