Ferreteria/v0.6/clade/Sys/Data/Engine/aux/ActionRq/Admin/dbase/EngDbExport

From Woozle Writes Code
< Ferreteria‎ | v0.6‎ | clade‎ | Sys‎ | Data‎ | Engine‎ | aux‎ | ActionRq‎ | Admin
Revision as of 03:08, 27 November 2025 by Woozle (talk | contribs)
Jump to navigation Jump to search
clade: Sys\Data\Engine\aux\ActionRq\Admin\dbase\EngDbExport
Clade Family
ToDbOper EngDbExport (none)
Clade Aliases
Alias Clade
Base* [ca,i] Sys\Data\Engine\aux\ActionRq\Admin\ToDbOper
File* [c] Sys\FileSys\Node\Fi
Request* [i] Sys\Data\Engine\aux\ActionRq\Admin
Subpages

History

  • 2024-12-03 [NOTE] mariadb-dump has an --xml / -X option which outputs in XML.
    • #TODO: experiment with this.
  • 2024-11-22 started
  • 2025-01-21 AskEngine() was calling a separate DoDbaseBackup() method right at the end, but I think this was just complicating things and confusing to read -- nothing else calls that. I've recombined them.
  • 2025-03-25 moved from AdminRq/ to AdminRq/ToDbConn/
  • 2025-09-21 renaming from Backup to EngDbExport, for consistency and clarity
  • 2025/10/08: fixing the call to FromParams()
  • 2025-10-09 Had to split off a trait in order to avoid Go() always overriding Go() from included traits in podlings.

Code

interface iEngDbExport extends BaseIface {}
abstract class caEngDbExport extends BaseClass implements iEngDbExport {

    // ++ CONFIG ++ //

    abstract protected function EngScExportRequestClass() : string;

    // -- CONFIG -- //
    // ++ ACTION ++ //

    // CEMENT
    public function Go() {
        $oScrn = self::Screen();

        $oDBC = $this->QDbOper()->GetIt();
        $oTplt = $this->FileSpecTemplate();
        $oTplt->Lookup()->QEngine()->SetIt($oDBC);

        $oTplt = $this->FileSpecTemplate();
        $oLook = $oTplt->Lookup();  // filename template

        $arSch = $oDBC->SchemaList();
        $nSch = count($arSch);
        if ($nSch == 0) {
            echo $oScrn->ErrorIt('Problem').': no schemas found.'.CRLF;
            $ok = FALSE;
        } else {
            $ok = TRUE;
            echo $nSch.' schema'.(($nSch==1)?'':'s').' found.'.CRLF;
            foreach ($arSch as $oSchema) {
                $oLook->QSchema()->SetIt($oSchema); // provide schema info for template ($oTplt)
                $fsData = $oTplt->Render();
                $ofData = FileClass::FromSpec($fsData);

                #$oSchReq = $this->NewEngScExportRequest();
                $sc = $this->EngScExportRequestClass();
                echo $sc::ReflectSelf()->Report();
                $oSchReq = $sc::FromParams($oSchema,$ofData);
                $oSchReq->Go();

            }
        }
        if ($ok) {
            echo $oScrn->GreenIt('Ok!').' - Backup complete.'.CRLF;
        } else {
            echo $oScrn->YellowIt('Note').': - one or more issues were found during backup.'.CRLF;
        }
    }

    // -- ACTION -- //
    // ++ OBJECTS ++ //

    protected function FileSpecTemplate() : TemplateIface { return FilePaths::Me()->ExportFiTplt(); }

    // -- OBJECTS ++ //
}