sqlMigrate : Allow Debug to display the executed INSERT

This commit is contained in:
2021-03-16 15:31:48 +01:00
parent aeab871d9d
commit cde2738fe9

View File

@@ -61,6 +61,7 @@ class main
$getopts = new getopts (); $getopts = new getopts ();
$getopts->add ("Help", "?h", array ("help"), "Help of the software"); $getopts->add ("Help", "?h", array ("help"), "Help of the software");
$getopts->add ("Step", "", array ("step:"), "Restart at provided step", "StepIdentifier"); $getopts->add ("Step", "", array ("step:"), "Restart at provided step", "StepIdentifier");
$getopts->add ("Debug", "", array ("debug"), "Display the SQL requests");
if ($getopts->get ("Help")) if ($getopts->get ("Help"))
die ($getopts->help ()); die ($getopts->help ());
if ($getopts->get ("Step")) if ($getopts->get ("Step"))
@@ -327,12 +328,15 @@ class main
$dstDB->primary ($dstSchema["primary"]); $dstDB->primary ($dstSchema["primary"]);
foreach ($srcDB->directQuery ($sql) as $row) foreach ($srcDB->directQuery ($sql) as $row)
{ {
echo ".";
//print_r ($row); //print_r ($row);
$dstDB->clearRequest (); $dstDB->clearRequest ();
$dstDB->insert () $dstDB->insert ()
->setValues ($row) ->setValues ($row);
->execute (); if (! $getopts->get ("Debug"))
echo ".";
else
echo $dstDB->getDisplayQuery ();
$dstDB->execute ();
} }
echo "\n"; echo "\n";
} }