/** * Model dla klasy {$className} * * @author ModGen */ class {$className} extends DataObject{literal}{{/literal} /** * nazwa tabeli */ static $tableName = '{$tableName}'; /** * nazwa klucza tabeli */ static $classTablePK = 'id_{$tableName}'; /** * nazwa klasy */ static $className = __CLASS__; /** * tablica mapująca pola klasy */ static $fields = array( {foreach from=$columnNames key=sqlName item=phpName name=fields} '{$sqlName}' => '{$phpName}'{if !$smarty.foreach.fields.last}, {else} {/if} {/foreach} ); {foreach from=$columnNames item=phpName name=fields} {if $phpName == 'id'} protected ${$phpName}; {else} private ${$phpName}; {/if} {/foreach} {*foreach from=$refTables item=phpName name=fields} public ${$phpName}; {/foreach*} // -- Konstruktor -- function __construct({foreach from=$columnNames item=phpName name=const}{if $phpName == 'id'} $id = -1 {else} ${$phpName} = null{/if}{if !$smarty.foreach.const.last},{/if}{/foreach}){literal}{{/literal} {foreach from=$columnNames item=phpName} $this->{$phpName} = ${$phpName}; {/foreach} {literal}}{/literal} // -- Get-y i Set-y -- {foreach from=$columnNames item=phpName} public function get{$phpName|ucfirst}(){literal}{{/literal} return $this->{$phpName}; {literal}}{/literal} public function set{$phpName|ucfirst}(${$phpName}){literal}{{/literal} $this->{$phpName} = ${$phpName}; {literal}}{/literal} {/foreach} {literal} /** * Pobiera nazwę tabeli reprezentującej obiekt w SQL * @return string */ public function GetTableName(){ return self::$tableName; } /** * Pobiera nazwę klucza głównego tabeli * @return string */ public function GetClassTablePK() { return self::$classTablePK; } /** * Pobiera tablice mapującą pola klasy na pola tabeli * @return array */ public function GetFields(){ return self::$fields; } /** * Pobiera nazwę klasy * @return string */ public function GetClassName(){ return self::$className; } {/literal} {literal}}{/literal}