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

From Woozle Writes Code
< Ferreteria‎ | v0.6‎ | clade‎ | Sys‎ | Data‎ | Engine‎ | aux‎ | ActionRq‎ | Admin
Revision as of 03:22, 27 November 2025 by Woozle (talk | contribs) (Created page with "{{page/clade/v2 |fam= {{!}} align=right {{!}} <code>{{l/ver/clade|Sys\Data\Engine\aux\ActionRq|Admin}}</code> {{!}} align=center {{!}} ⇒ <code>{{l/ver/clade|Sys\Data\Engine\aux\ActionRq\Admin|dbase}}</code> ⇒ {{!}} align=left {{!}} ''(none)'' |alia= {{!-!}} '''Base'''* [ca,i] {{!!}} <code>{{l/ver/clade/full|Sys\Data\Engine\aux\ActionRq|Admin}}</code> {{!-!}} '''DbOperIface''' {{!!}} <code>{{l/ver/clade/full|Sys\Data\Engine|Oper}}</code> }} ==About== * '''...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
clade: Sys\Data\Engine\aux\ActionRq\Admin\dbase\EngDbScList
Clade Family
Admin dbase (none)
Clade Aliases
Alias Clade
Base* [ca,i] Sys\Data\Engine\aux\ActionRq\Admin
DbOperIface Sys\Data\Engine\Oper
Subpages

About

  • Purpose: DB-Engine operation for listing Schemas in the database

History

  • 2024-12-10 started
  • 2025-09-21 renamed from ListSchemasEngDbScList (after a brief sojourn at EngDbListSchemas), for contextual clarity

Code

interface iEngDbScList extends BaseIface {}
abstract class caEngDbScList extends BaseClass implements iEngDbScList {

    // ++ ACTION ++ //

    // CEMENT/DEFAULT: entry point
    public function Go() {
      $this->AmHere();
        $oaReq = $this->OASavedInput();
        $qoOper = $oaReq->QODbOper();
        $oItWent = $qoOper->HowItWent();
      $this->AmHere();
        if ($oItWent->WasTried()) {
            if ($oItWent->GetOkay()) {
                // success
                if ($qoOper->HasIt()) {
      $this->AmHere();
                    $this->UseDbOper($qoOper->GetIt());
      $this->AmHere();
                } else {
                    // WORKING HERE 2025-10-01
                    $this->AmHere();
                }
            } else {
                $this->HandleBadLoad($oItWent);
            }
        } else {
            echo '(No action attempted.)'.CRLF;
        }
    }

    // ++ ACTION: components ++ //

    // PURPOSE: we have the DB object, so do the thing
    // DEFAULT (It's not entirely right for this to be here instead of app-specific, but it'll do for now.)
    protected function UseDbOper(DbOperIface $oOper) {
        $ar = $oOper->SchemaList();
        $nDBs = count($ar);
        echo $nDBs.' schema'.(($nDBs==1)?'':'s').' found:'.CRLF;
        foreach ($ar as $oSchema) {
            $sSchema = $oSchema->SchemaName();
            echo " - $sSchema".CRLF;
        }
    }
    protected function HandleBadLoad($oItWent) {

        if ($oItWent->HasError()) {
            switch ($oItWent->GetError()) {
              case $oItWent::N_ERR_DB_DEFN:
                $this->HandleBadSlug();
                break;
              case $oItWent::N_ERR_DB_SLUG:
                $this->HandleNoSlug();
                break;
              default:
                $this->HandleMystery();
            }
        }
    }

    // 2025-10-01 Possibly these behaviors (below) should be app-specific, but this at least gets the ball rolling.

    protected function HandleBadSlug() {
        // DEFAULT: list all configured DBs (so user can hopefully correct their mistake)
        $sSlug = $this->QSDbConn()->GetIt();
        $vsSlug = self::Screen()->WarnIt($sSlug);
        echo "Database slug [$vsSlug] not found. Here's what is available:".CRLF;
        echo $this->ListHosts();
    }
    protected function HandleNoSlug() {
        echo "No database slug specified; here's what is available:".CRLF;
        echo $this->ListHosts();
    }
    protected function HandleMystery() {
        echo $oItWent->RenderMessages();
                    $this->AmHere();
    }

    // -- ACTION -- //
}