src/Generator/templates/table_trait.mustache
<?php
/* This file is generated by the open source Parm Generator. github.com/cassell/Parm */
{{#namespaceClassSyntax}}
{{namespaceClassSyntax}}
{{/namespaceClassSyntax}}
trait {{className}}TableFunctions
{
/**
* Get the "logical" table name associated. The configuration can point to a different database name.
* @return string
*/
static function getDatabaseName()
{
return '{{databaseName}}';
}
/**
* Get the table name associated with this object
* @return string
*/
public static function getTableName()
{
return '{{tableName}}';
}
{{#id.exists}}
/**
* Get the column name of the primary key field
* @return string The primary key column name
*/
public static function getIdField()
{
return {{className}}Table::{{id.columnNameAllCaps}}_COLUMN;
}
{{/id.exists}}
{{^id.exists}}
/**
* This table or view does not have a primary key
* @return string The primary key column name
*/
public static function getIdField()
{
return null;
}
{{/id.exists}}
/**
* Get the factory associated with this object
* @return {{className}}DaoFactory A DAO Factory
*/
static function getFactory(\Doctrine\DBAL\Connection $connection = null)
{
return new {{className}}DaoFactory($connection);
}
/**
* Get the list of columns in {{tableName}} from logical database "{{databaseName}}"
* @return Array Array of field names
*/
public static function getFields()
{
return array({{fieldList}});
}
/**
* Load an object associated with this factory
* @return {{className}}DaoObject An object built from a row out of the database table
*/
public function loadDataObject(Array $row)
{
return new {{className}}DaoObject($row);
}
public final static function getDefaultRow()
{
return array({{{defaultValuePack}}});
}
}