Ferreteria/v0.6/clade/Sys/Data/aux/has/Schema

From Woozle Writes Code
< Ferreteria‎ | v0.6‎ | clade‎ | Sys‎ | Data‎ | aux
Jump to navigation Jump to search
clade: Sys\Data\aux\has\Schema
Clade Family
(root) Schema Admin

Code

as of 2025-10-04

interface iSchema {
    // SETTINGS
    function QSSchema() : QStrIface;
    function QOSchema() : QObjIface;
}
// REQUIRES: tDbConn
trait tSchema {

    protected function NewSchema() : SchemaIface {
        self::PromptForMethod();    // 2025-02-02 to be written, I presume
    }

    // schema name
    private $osSchm=NULL;
    public function QSSchema() : QStrIface { return $this->osSchm ?? ($this->osSchm = QStrClass::AsNew()); }

    // schema object
    protected $ooSchm=NULL;
    public function QOSchema() : QObjIface {
        $oo = $this->ooSchm;
        if (is_object($oo)) {
            $doTry = !$oo->HasIt();
        } else {
            $oo = QObjClass::AsNew();
            $doTry = TRUE;
            $this->ooSchm = $oo;
        }
        if ($doTry) {
            $os = $this->QSSchema();    // Schema name
            if ($os->HasIt()) {
                $sSch = $os->GetIt();
                $oConn = $this->ODbConn();  // creates new DB object if needed
                $oSch = $oConn->GetSchema($sSch);
                $oo->SetIt($oSch);
            }
        }
        return $oo;
    }
}