Ferreteria/v0.5/table/spec

From Woozle Writes Code
< Ferreteria‎ | v0.5‎ | table
Jump to navigation Jump to search

Table Spec classes

Table spec classes from data/db/tables/spec.php:

class cQuery {
    private $ar;

    public function __construct(array $arArgs) { $this->ar = $arArgs; }
    
    protected function HasArg(string $sName) : bool { return array_key_exists($this->ar,$sName); }
    protected function GetArg(string $sName) : string { return $this->ar[$sName]; }
    
    public function SpecName() : string { return $this->GetArg('.'); }
    public function DatabaseSlug() : string { return $this->GetArg('db'); }
    
    public function Database() : FD\caDatabase { return FD\csStocker::MakeEngine($this->DatabaseSlug()); }
}
class cTable extends cQuery {

    public function TableSQName() : string { return $this->GetArg('sql'); }
    
    public function Table() : cTabloid { return $this->Database()->MakeTable($this->TableSQName()); }
}
class cTableK1I extends cTable {
    public function KeyName() : string { return $this->GetArg('key'); }
    public function ActionSlug() : string {
        $skName = 'aslug';
        if ($this->HasArg($skName)) {
            return $this->GetArg($skName);
        } else {
            return $this->SpecName();
        }
    }
}