Ferreteria/v0.6/clade/Sys/Data/Engine/aux/ActionRq/Admin/dbase/EngDbScList
Jump to navigation
Jump to search
| ||||||||||||||||
About
- Purpose: DB-Engine operation for listing Schemas in the database
History
- 2024-12-10 started
- 2025-09-21 renamed from
ListSchemas⇒EngDbScList(after a brief sojourn atEngDbListSchemas), 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 -- //
}