Ferreteria/v0.6/clade/Sys/Data/Engine/schema/Ops/MyMar/@fx/DoImport
Jump to navigation
Jump to search
About
- General: DoImport
About
- Action: import SQL data via command-line
Status
Code
#
public function DoImport(FileIface $ofData, bool $okToReplace) : ActionIface {
$oScrn = self::Screen();
$oAct = new ActionClass;
#echo $this->ReflectThis()->Report();
$sSchema = $this->QSchemaName()->GetIt();
$oDBC = $this->DbConn();
// 2025-06-05 TODO: get this from the Creds object now --
$sCreds = $oDBC->CredsForCmd(); // db (inside) connection string
#echo $ofData->Ident()->ReflectThis()->Report();
$fsData = $ofData->Ident()->SpecFull();
$ftFile = $oScrn->BlueIt($fsData);
$ftSchema = $oScrn->GreenIt($sSchema);
// Check to see if schema already exists
if ($oDBC->OOper()->SchemaExists($sSchema)) {
echo $oScrn->InfoIt('Found')." schema [$ftSchema]...".CRLF;
#echo $this->ReflectThis()->Report();
if ($okToReplace) {
$sCmd = "echo 'CREATE OR REPLACE DATABASE $sSchema;'