Futilities/v0.6/clade/Sys/dba/InRqData: Difference between revisions

From Woozle Writes Code
< Futilities‎ | v0.6‎ | clade‎ | Sys‎ | dba
Jump to navigation Jump to search
No edit summary
mNo edit summary
Line 37: Line 37:
** <code>function {{l/ver/fx|QODbConn}}() : QObjIface;</code>
** <code>function {{l/ver/fx|QODbConn}}() : QObjIface;</code>
** <code>function {{l/ver/fx|QOSchema}}() : QObjIface;</code>
** <code>function {{l/ver/fx|QOSchema}}() : QObjIface;</code>
}}
 
===Source===
===Source===
''as of 2025-10-23''
''as of 2025-10-23''

Revision as of 14:25, 24 October 2025

clade: Sys\dba\InRqData
Clade Family
[WFe]InRqData InRqData (none)
Clade Aliases
Alias Clade
Base* [c,i] Sys\Events\InputRq\aux\InRqData
DbConnIface Sys\Data\Engine\Conn
KioskEnum Sys\dba\Kiosk
QObj* [c,i] Data\Mem\QVar\Obj
QStr* [c,i] Data\Mem\QVar\Str
SchemaIface Sys\Data\Engine\Schema
Subpages

About

  • PURPOSE: input-request data manager for DBA

This provides the interface to the data storage, not the interface to input data parsing.

History

  • 2025-01-23 (InReq/data/in/Dbase.php) created

Source

Purpose

This encapsulates the user input handled by The Futilities DBA command, adding access-functions for DBA-specific command-inputs.

Access-functions generally act on named entries in the base cInRqData object, using names supplied by DBA's KioskEnum (eKiosk).

Code

Functions

Source

as of 2025-10-23

trait tInRqData { // for users of this format
    // ++ CONFIG ++ //

    // UNPROMPT for dba command (do not override in podlings)
    static protected function InputClass() : string { return cInRqData::class; }

    // -- CONFIG -- //
}
interface iInRqData extends BaseIface {
    // DATA
    function QDbConnSlug() : QStrIface;
    function QSchemaSlug() : QStrIface;
    function OkToReplace() : bool;
    // OBJECTS
    function QODbConn() : QObjIface;
    function QOSchema() : QObjIface;
}
class cInRqData extends BaseClass implements iInRqData {

    // ++ DATA ++ //

    public function QDbConnSlug() : QStrIface { return $this->FetchItQ(KioskEnum::VAL_CONN->value);  }
    public function QSchemaSlug() : QStrIface { return $this->FetchItQ(KioskEnum::VAL_SCHEMA->value); }

    public function OkToReplace() : bool {
        #$sName = 'xf.replace';
        $sName = KioskEnum::VAL_REPLACE->value;
        $obVal = $this->FetchItQ($sName);
        $bVal = $obVal->HasIt() ? $obVal->GetIt() : FALSE;
        return $bVal;
    }

    // -- DATA -- //
    // ++ OBJECTS ++ //

    private $oqDbConn=NULL;
    public function QODbConn() : QObjIface {
        $oo = $this->oqDbConn;
        if (is_object($oo)) {
            $bDoGet = !$oo->HasIt();
        } else {
            $qo = QObjClass::AsNew();
            $bDoGet = TRUE;
            $this->oqDbConn = $oo;
        }
        if ($bDoGet) {
          echo $this->ReflectThis()->Report();
            $qo->SetIt($this->ODbConn());
        }
        return $qo;
    }
    /*
    protected function NewDbConn() : DbConnIface {
        // TODO
    }
    */

    private $oqSchema=NULL;
    public function QOSchema() : QObjIface {
        $oo = $this->oqSchema;
        if (is_object($oo)) {
            $bDoGet = !$oo->HasIt();
        } else {
            $oo = QObjClass::AsNew();
            $bDoGet = TRUE;
            $this->oqSchema = $oo;
        }
        #$this->AmHere("bDoGet=[$bDoGet]");
        if ($bDoGet) {
            $os = $this->QSchemaSlug();    // Schema name-slug
            #$this->AmHere();
            if ($os->HasIt()) {
                $this->AmHere();
                $sSch = $os->GetIt();
                $oqDbConn = $this->QODbConn();
                if ($oqDbConn->HasIt()) {
                    $oDbConn = $oqDbConn->GetIt();
                    $oSch = $oDbConn->GetSchema($sSch);
                    $oo->SetIt($oSch);
                }
            } else {
                echo 'INPUT: '.$this->Inspect()->Render().CRLF;
            }
        }
        return $oo;
    }

    // -- OBJECTS -- //
    // ++ OUTPUT ++ //

    // OVERRIDE
    public function Debug_Render() : string {
        $ar = $this->GetVals();
        $nAr = count($ar);
        if ($nAr > 0) {
            if ($nAr > 1) {
                $sOut = $nAr.' input elements:'.CRLF;
            } else {
                $sOut = 'One input element: ';
            }
            foreach ($ar as $sKey => $sVal) {
                $sOut .= "[$sKey] => [$sVal]".CRLF;
            }
        } else {
            $sOut = 'No elements in input array.'.CRLF;
        }

        return $sOut;

    }

    // -- OUTPUT -- //
}

Removed

2025-10-08

Commented out at the end of July:

// 2025-07-29 added but probably don't need
use Woozalia\Ferret\Sys\Data\Engine\{
    iConn as OperIface,
    caOps as OperAdmin,
    iOps as OperIface,
};

2025-03-10

Added code yesterday to see if this code is still in use, and it was not triggered:

// ++ SETUP: pieces ++ //

    // CEMENT
    protected function UseContent(string $s) : void {
      self::GotToHere('2025-03-08 Is this still being called?'); die();
        #$arPcs = explode('/',$s);  // 2025-01-22 This is a bit of a kluge
        $this->QRaw()->SetIt($s);
        $arPcs = $this->ValueArray();
        $nPcs = count($arPcs);
        switch($nPcs) {
          case 0:
            echo 'Indicate what and where to import like this: "write:{db name}/{schema name}".'.CRLF;
            break;
          case 1:
            $sDB = $arPcs[0];
            echo 'Indicate which file to import like this: "write:'.$sDB.'/{schema name}".'.CRLF;
            $this->QDbConnSlug()->SetIt($sDB);
            break;
          default:    // 2 or more
            [$sDbase,$sSchema] = $arPcs;
            $this->QDbConnSlug()->SetIt($sDbase);
            $this->QSchemaName()->SetIt($sSchema);
            break;
        }
    }

    // -- SETUP -- //

Commented out days/weeks ago, not sure why except that it seemed to be unused (and looking at it now, it's probably the wrong way to do it anyway):

// ++ ACCESS: kept ++ //

    static private $osSch = NULL;
    public function KeptQSchema() : QObjIface { return self::$osSch ?? (self::$osSch = $this->NewQSchema()); }
    protected function NewQSchema() : QObjIface { return QObjClass::FromNone(); }

    // ++ ACCESS: best ++ //

    public function QSchemaName() : QStrIface {
        $os = $this->GetItQ('xf.schema');
        if (!$os->HasIt()) {
            $os = $this->Latest()->GetItQ('xf.schema');
        }
        return $os;
    }