Ferreteria/v0.3/class/tHasTableSource: Difference between revisions

From Woozle Writes Code
< Ferreteria‎ | v0.3‎ | class
Jump to navigation Jump to search
m (Woozle moved page Ferreteria/class/tTableSource to Ferreteria/class/tHasTableSource: more descriptive)
No edit summary
Line 1: Line 1:
{{page/code/class|ferreteria}}
{{page/code/class|ferreteria}}
<source lang=php>
<source lang=php>
trait tTableSource {
/*tttt
  STANDARD USE: storage PortalRow class
*/
trait tHasTableSource {
     use tQueryableSource;
     use tQueryableSource;
    private $db;
    public function SetDatabase(cDatabaseConnection $db) {
$this->db = $db;
    }
    protected function GetDatabase() : cDatabaseConnection {
if (is_null($this->db)) {
    $sClass = get_class($this);
    throw new \exception("Tried to retrieve db object before it has been set in class '$sClass'.");
}
return $this->db;
    }


     abstract protected function GetTableName();
     abstract protected function GetTableName();
Line 27: Line 18:
</source>
</source>
* '''file''': {{l/ferreteria/file|data/basic/source.php}}
* '''file''': {{l/ferreteria/file|data/basic/source.php}}
* '''uses''': {{l/ferreteria/class|tQueryableSource}}
* '''used by''': {{l/ferreteria/class|cStandardTable}}
* '''replaces''':
* '''replaces''':
** {{l/ferreteria/class|cIOSource_db}}
** {{l/ferreteria/class|cIOSource_db}}
** most of {{l/ferreteria/class|cIOSource_standard_table}}
** most of {{l/ferreteria/class|cIOSource_standard_table}}

Revision as of 13:19, 7 January 2019

Template:Page/code/class

/*tttt
  STANDARD USE: storage PortalRow class
*/
trait tHasTableSource {
    use tQueryableSource;

    abstract protected function GetTableName();
    
    // ALIAS
    protected function SourceString_forSelect() {
        $sName = $this->GetTableName();
        return "`$sName`";
    }

}