Futilities/v0.6/clade/Sys/dba/InRqData: Difference between revisions
< Futilities | v0.6 | clade | Sys | dba
Jump to navigation
Jump to search
| (3 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
{{page/clade | {{page/clade/v2 | ||
|fam= | |||
! | {{!}} align=right {{!}} [WFe]{{l/ver/clade|p=ferreteria|Sys\Events\InputRq\aux|InRqData}} | ||
{{!}} align=center {{!}} → {{l/ver/clade|Sys\dba|InRqData}} → | |||
{{!}} align=left {{!}} ''(none)'' | |||
{| | |alia= | ||
! | {{!-!}} '''Base'''* [c,i] {{!!}} {{l/ver/clade/full|p=ferreteria|Sys\Events\InputRq\aux|InRqData}} | ||
{{!-!}} '''DbConnIface''' {{!!}} {{l/ver/clade/full|p=ferreteria|Sys\Data\Engine|Conn}} | |||
! | {{!-!}} '''KioskEnum''' {{!!}} {{l/ver/clade/full|p=futilities|Sys\dba|Kiosk}} | ||
{{!-!}} '''QObj'''* [c,i] {{!!}} {{l/ver/clade/full|p=ferreteria|Data\Mem\QVar|Obj}} | |||
{{!-!}} '''QStr'''* [c,i] {{!!}} {{l/ver/clade/full|p=ferreteria|Data\Mem\QVar|Str}} | |||
{{!-!}} '''SchemaIface {{!!}} {{l/ver/clade/full|p=ferreteria|Sys\Data\Engine|Schema}} | |||
|} | |||
}} | |||
== | ==About== | ||
* ''' | * PURPOSE: input-request data manager for DBA | ||
This clade encapsulates the user input handled by The [[Futilities]] [[Futilities/dba|DBA command]], adding access-functions for DBA-specific command-inputs. | |||
Note: It provides the interface to the data ''storage'', not the interface to input data ''parsing''. | |||
Access-functions generally act on named entries in the base c{{l/ver/clade|p=Ferreteria|Sys\Events\InputRq\aux|InRqData}} object, using names supplied by DBA's KioskEnum (e{{l/ver/clade|Sys\dba|Kiosk}}). | |||
==History== | |||
* '''{{fmt/date|2025|01|23}}''' (InReq/data/in/Dbase.php) created | |||
==Code== | |||
===Sources=== | |||
* '''docs''': [https://gitlab.com/woozalia/ferreteria/-/blob/v0.6-dev/apps/futils/src/Sys/dba/InRqData.md v0.6-dev] | * '''docs''': [https://gitlab.com/woozalia/ferreteria/-/blob/v0.6-dev/apps/futils/src/Sys/dba/InRqData.md v0.6-dev] | ||
== | ===Functions=== | ||
* // DATA | |||
** <code>function {{l/ver/fx|QDbConnSlug}}() : QStrIface;</code> | |||
** <code>function {{l/ver/fx|QSchemaSlug}}() : QStrIface;</code> | |||
** <code>function {{l/ver/fx|OkToReplace}}() : bool;</code> | |||
* // OBJECTS | |||
** <code>function {{l/ver/fx|QODbConn}}() : QObjIface;</code> | |||
** <code>function {{l/ver/fx|QOSchema}}() : QObjIface;</code> | |||
===Source=== | |||
* '''repo''': [https://gitlab.com/woozalia/ferreteria/-/blob/v0.6-dev/apps/futils/src/Sys/dba/InRqData.php v0.6-dev] | |||
''as of 2025-10-23'' | |||
{{fmt/php/block|1= | {{fmt/php/block|1= | ||
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 | // DATA | ||
function QDbConnSlug() : QStrIface; | function QDbConnSlug() : QStrIface; | ||
| Line 37: | Line 58: | ||
function QODbConn() : QObjIface; | function QODbConn() : QObjIface; | ||
function QOSchema() : 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=== | |||
===={{fmt/date|2025|11|15}}==== | |||
Commented out today: | |||
{{fmt/php/block|1= | |||
// ++ OBJECTS ++ // | |||
// 2025-11-15 Now using SchemerTrait implementation. | |||
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; | |||
} | |||
if ($bDoGet) { | |||
$os = $this->QSchemaSlug(); // Schema name-slug | |||
if ($os->HasIt()) { | |||
$sSch = $os->GetIt(); | |||
#echo $this->ReflectThis()->Report(); | |||
$qoDbOper = $this->QODbOper(); | |||
if ($qoDbOper->HasIt()) { | |||
$oDbOper = $qoDbOper->GetIt(); | |||
$oSch = $oDbOper->GetSchema($sSch); | |||
$oo->SetIt($oSch); | |||
} | |||
/* 2025-10-30 Not correct anymore. | |||
$oqDbConn = $this->QODbConn(); | |||
if($oqDbConn->HasIt()) { | |||
$oDbConn = $oqDbConn->GetIt(); | |||
#echo $this->ReflectThis()->Report(); | |||
$oSch = $oDbConn->GetSchema($sSch); | |||
$oo->SetIt($oSch); | |||
} | |||
* / | |||
} else { | |||
// | |||
echo "INPUT: ".$this->Inspect()->Render(); | |||
echo '(TODO 2025-11-13: Decode the input internal-names so we can prompt the user more precisely.)'.CRLF; | |||
} | |||
} | |||
return $oo; | |||
} | |||
// -- OBJECTS -- // | |||
}} | |||
Commented out on {{fmt/date|2025|10|27}}: | |||
{{fmt/php/block|1= | |||
// 2025-10-27 now implemented in [WFe]Sys\Data\Engine\aux\ActionRq\Admin\ToDbConn | |||
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 = $qo; | |||
} | |||
if ($bDoGet) { | |||
$qo->SetIt($this->ODbConn()); | |||
} | |||
return $qo; | |||
} | |||
}} | |||
===={{fmt/date|2025|10|08}}==== | |||
Commented out at the end of July: | |||
{{fmt/php/block|1= | |||
// 2025-07-29 added but probably don't need | |||
use Woozalia\Ferret\Sys\Data\Engine\{ | |||
iConn as OperIface, | |||
caOps as OperAdmin, | |||
iOps as OperIface, | |||
}; | |||
}} | |||
===={{fmt/date|2025|03|10}}==== | |||
Added code yesterday to see if this code is still in use, and it was not triggered: | |||
{{fmt/php/block|1= | |||
// ++ 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): | |||
{{fmt/php/block|1= | |||
// ++ 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; | |||
} | |||
}} | }} | ||
Latest revision as of 18:43, 15 November 2025
| ||||||||||||||||||||||||
About
- PURPOSE: input-request data manager for DBA
This clade encapsulates the user input handled by The Futilities DBA command, adding access-functions for DBA-specific command-inputs.
Note: It provides the interface to the data storage, not the interface to input data parsing.
Access-functions generally act on named entries in the base cInRqData object, using names supplied by DBA's KioskEnum (eKiosk).
History
Code
Sources
- docs: v0.6-dev
Functions
- // DATA
function QDbConnSlug() : QStrIface;function QSchemaSlug() : QStrIface;function OkToReplace() : bool;
- // OBJECTS
Source
- repo: v0.6-dev
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-11-15
Commented out today:
// ++ OBJECTS ++ //
// 2025-11-15 Now using SchemerTrait implementation.
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;
}
if ($bDoGet) {
$os = $this->QSchemaSlug(); // Schema name-slug
if ($os->HasIt()) {
$sSch = $os->GetIt();
#echo $this->ReflectThis()->Report();
$qoDbOper = $this->QODbOper();
if ($qoDbOper->HasIt()) {
$oDbOper = $qoDbOper->GetIt();
$oSch = $oDbOper->GetSchema($sSch);
$oo->SetIt($oSch);
}
/* 2025-10-30 Not correct anymore.
$oqDbConn = $this->QODbConn();
if($oqDbConn->HasIt()) {
$oDbConn = $oqDbConn->GetIt();
#echo $this->ReflectThis()->Report();
$oSch = $oDbConn->GetSchema($sSch);
$oo->SetIt($oSch);
}
* /
} else {
//
echo "INPUT: ".$this->Inspect()->Render();
echo '(TODO 2025-11-13: Decode the input internal-names so we can prompt the user more precisely.)'.CRLF;
}
}
return $oo;
}
// -- OBJECTS -- //
// 2025-10-27 now implemented in [WFe]Sys\Data\Engine\aux\ActionRq\Admin\ToDbConn
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 = $qo;
}
if ($bDoGet) {
$qo->SetIt($this->ODbConn());
}
return $qo;
}
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;
}