|
@@ -21,7 +21,9 @@ class CreateYamlForImportCommand extends ContainerAwareCommand
|
|
->setDescription('Create yaml for import.')
|
|
->setDescription('Create yaml for import.')
|
|
->setHelp('Create yaml from table.')
|
|
->setHelp('Create yaml from table.')
|
|
->addArgument('table', InputArgument::REQUIRED, "Table name to export data.")
|
|
->addArgument('table', InputArgument::REQUIRED, "Table name to export data.")
|
|
- ->addArgument('file-name', InputArgument::REQUIRED, "Name of the file.");
|
|
|
|
|
|
+ ->addArgument('file-name', InputArgument::REQUIRED, "Name of the file.")
|
|
|
|
+ ->addOption("where", null, InputOption::VALUE_OPTIONAL, "Where for sql sentece.", "")
|
|
|
|
+ ->addOption("action", null, InputOption::VALUE_OPTIONAL, "Action for sql sentencies. Options: INSERT, UPDATE, DELETE, REPLACE, INSERTORUPDATE, INSERTIGNORE", "INSERTORUPDATE");
|
|
}
|
|
}
|
|
|
|
|
|
protected function execute(InputInterface $input, OutputInterface $output)
|
|
protected function execute(InputInterface $input, OutputInterface $output)
|
|
@@ -30,10 +32,11 @@ class CreateYamlForImportCommand extends ContainerAwareCommand
|
|
$table = $input->getArgument('table');
|
|
$table = $input->getArgument('table');
|
|
$fileName = $input->getArgument('file-name');
|
|
$fileName = $input->getArgument('file-name');
|
|
|
|
|
|
- $stmt = $em->getConnection()->executeQuery("select * from " . $table);
|
|
|
|
|
|
+ $stmt = $em->getConnection()->executeQuery("select * from " . $table .
|
|
|
|
+ (trim($input->getOption("where")) == '' ? '' : ' where ' . $input->getOption("where")));
|
|
if ($stmt->rowCount() > 0) {
|
|
if ($stmt->rowCount() > 0) {
|
|
$result = $stmt->fetchAll();
|
|
$result = $stmt->fetchAll();
|
|
- $str = "insertorupdate:\n";
|
|
|
|
|
|
+ $str = $input->getOption("action") . ":\n";
|
|
$str .= " $table:\n";
|
|
$str .= " $table:\n";
|
|
foreach ($result as $row) {
|
|
foreach ($result as $row) {
|
|
$first = true;
|
|
$first = true;
|