Ferreteria/v0.6/clade/Sys/Data/Engine/schema/Ops/MyMar/@removed

From Woozle Writes Code
< Ferreteria‎ | v0.6‎ | clade‎ | Sys‎ | Data‎ | Engine‎ | schema‎ | Ops‎ | MyMar
Jump to navigation Jump to search
Removed Code

2026-01-08

Commented out from @fx/DoImport() (after $oAct->Assimilate($oActConn);) on 2026-01-04:

#
            /* 2026-01-04 This is kind of all messed-up.
            // create buffer for sending commands:
            $oReplyBuff = new BufferClass; // buffer for brief replies (not for file-storage)
            $oAct = $oReplyBuff->Open();

            // ** FIRST: create/replace the database as determined earlier

            $oConnx = $oDbConn->OSock();
            $this->AmHere("SQL: $sqCmd");
            #echo $oDbConn->ReflectThis()->Report(); die();
            $oAct = $oDbConn->DoCommand($sqCmd,$oReplyBuff);
            if ($oAct->GetOkay()) {
                $oDbConn->Send($

                // ** AND THEN: import the data

                echo $oScrn->InfoIt('Importing')." from file [$ftFile]...".CRLF;

                // This version expects the data to be sent separately, and should also work remotely.
                $sCmd = "mysql $sCreds -D$sSchema";

                // Send CLI command, which opens a connection to the remote MyMar process:
                $oProc = $oConnx->OPlug()->RunProcess($sCmd);
                // create buffer for import data
                $oSendBuff = TextStreamClass::FromNode($ofData);
                // open data file for read-buffering:
                // send file's data:

                $oProc->Convey($oSendBuff,$oReplyBuff);
                echo CRLF.'Buffer sent.'.CRLF;
            } else {
                echo $oScrn->ErrorIt('Problem').": command to create the schema '$sSchema' did not succeed.".CRLF.$oAct->GetStatusText().CRLF;
            }

            #echo $oAct->ReflectThis()->Report();
            $oAct = $oDbConn->WrapAction($oAct);  // TODO: This is *coming* from DbConn -- shouldn't it already be properly wrapped?
            #echo $oDbConn->ReflectThis()->Report();
            $oDbOper->MsgsOp()->HandleResults($oAct);
            echo $oAct->RenderMessages(); // Does this duplicate stuff that HandleResults() does?
        } else {
            $this->AmHere('FAILED TO OPEN OUTPUT BUFFER');
            $sMsg = $oScrn->ErrorIt('Error').': Could not open output buffer.'.CRLF.$oAct->GetStatusText().CRLF;
            $oAct->AddMsgString($sMsg);
            $oAct->SetOkay(FALSE);
        }

I'm not actually sure if the code there now actually works... but it looks not-wrong. Possibly nothing actually uses RunProcess() anymore?

2025-04-12

From the middle of DoImport():

#
            // This version will only work locally.
            // This is probably faster than buffering...
            // ...but doesn't allow the possibility of showing progress since there's no middleman to audit the data stream.
            $sCmd = "mysql $sCreds -D$sSchema < $fsData";
            // NOTE: "--quick" can do line-at-a-time rather than buffering entire table
            // NOTE: "-D<arg>" = "--database=<arg>"

2025-01-26

This (commented out earlier, from DoBackup() which is now DoExport()) has probably been moved elsewhere, but I'm being paranoid:

#
        // TODO: include program name/version
        $sDateFmt = 'Y/m/d H:i:s';   // "/" chars get escaped, so "." makes the text a little more readable
        $arMeta['db.slug'] = $this->Engine()->ObjectSlug();
        $arMeta['schema'] = $sSchema;
        $arMeta['fspec'] = $fsData; // TODO: get just the filename
        $arMeta['time.start.int'] = time();
        $arMeta['time.start.str'] = date($sDateFmt);
        $fsMeta = $fsData.'.json';
        $jsMeta = json_encode($arMeta,JSON_PRETTY_PRINT);
        file_put_contents($fsMeta,$jsMeta);

This is from inside if ($oAct->GetOkay()) {:

#
            // TODO: integrate $oActBuff results
            if ($oAct->QResponseErr()->HasIt()) {
                $sMsg = trim($oAct->QResponseErr()->GetIt());
                $oScrn->ErrorIt('Error stream').': $sMsg'.CRLF;
            }

            // 2025-01-25 old message-handling
            $sMsg = trim($oAct->GetMessage());
            echo ' - ' . (($oAct->GetOkay() ? $oScrn->GreenIt('Done.') : ($oScrn->ErrorIt('Error: ').$sMsg))) . CRLF;

...and this is from after the if is closed:

#
        $arMeta['time.finish.int'] = time();
        $arMeta['time.finish.str'] = date($sDateFmt);
        $arMeta['status.cmd'] = $oAct->GetStatusText();
        if (is_object($oActBuff)) {
            $arMeta['status.buff'] = $oActBuff->GetStatusText();  // This may be unnecessary.
        }
        $jsMeta = json_encode($arMeta,JSON_PRETTY_PRINT);
        file_put_contents($fsMeta,$jsMeta); // update the metadata file