Ferreteria/v0.6/clade/Sys/Data/Engine/aux/Schema/MyMar/@fx/DoImport
Jump to navigation
Jump to search
About
- General: DoImport
About
- Action: import SQL data via command-line
Status
- 2025-02-11 #TODO There really should be a log.
- 2026-03-12 reworked
EnsureSchema(), requiring changes here too - 2026-03-27 process-management is being significantly reworked
Code
#
public function DoImport(FileIface $ofData, bool $okToReplace) : ActionIface {
$oScrn = self::Screen();
$oMode = ModeClass::FromCodes('R+');
$ofData->InOut()->Mode($oMode); // must be readable
$fsData = $ofData->Ident()->SpecFull();
$ftFile = $oScrn->BlueIt($fsData);
$oAct = new ActionClass;
$this->Open(); // open the connection now so it stays open between ops
// Run the Engine-process and leave it waiting for input
$oCmd = CommandClass::FromVoid();
#$this->AmHere();
$oActCmd = $this->OServer()->DoCommand($oCmd);
#$this->AmHere();
// Save a local pointer to the end-Runner:
#$oSvrEnd = $oCmd->QORunner()->GetIt();
$this->QORunner()->SetIt($oCmd->QORunner()->GetIt());
$oActEnsure = $this->EnsureSchema($okToReplace);
$oAct->SetOkay($oActEnsure->GetOkay());
if ($oActEnsure->GetOkay()) {
$oRun = $oActEnsure->QORunner()->GetIt();
$oActImport = $this->ImportFromFile($ofData,$oRun);
$this->AmHere('$oActImport:'.$oActImport->VIEW_AsBlock());
$oAct->Assimilate($oActImport);
#$this->AmHere('post-assimilate');
if ($oActImport->GetOkay()) {
$ftMsg = $oScrn->GreenIt('Ok!').' - Restore complete.'.CRLF;
$oAct->AddMsgString($ftMsg);
}
}
$this->Shut(); // done using the connection
return $oAct;
}