Class yii\gii\generators\model\Generator

Inheritanceyii\gii\generators\model\Generator » yii\gii\Generator
Subclasseshscstudio\heart\modules\gii\model\Generator
Available since version2.0
Source Code https://github.com/yiisoft/yii2/blob/master/extensions/gii/generators/model/Generator.php

This generator will generate one or multiple ActiveRecord classes for the specified database table.

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
checkPivotTable() Checks if the given table is a pivot table. yii\gii\generators\model\Generator
generateClassName() Generates a class name from the specified table name. yii\gii\generators\model\Generator
generateRelationLink() Generates the link parameter to be used in generating the relation declaration. yii\gii\generators\model\Generator
generateRelationName() Generate a relation name for the specified table and a base name. yii\gii\generators\model\Generator
generateRelations() yii\gii\generators\model\Generator
getDbConnection() yii\gii\generators\model\Generator
getTableNames() yii\gii\generators\model\Generator
isColumnAutoIncremental() Checks if any of the specified columns is auto incremental. yii\gii\generators\model\Generator

Property Details

$baseClass public property
$baseClass 'yii\db\ActiveRecord'
$classNames protected property
$classNames null
$db public property
$db 'db'
$generateLabelsFromComments public property
$generateRelations public property
$modelClass public property
$modelClass null
$ns public property
$ns 'app\models'
$tableName public property
$tableName null
$tableNames protected property
$tableNames null
$useTablePrefix public property
$useTablePrefix false

Method Details

attributeLabels() public method

void attributeLabels( )
autoCompleteData() public method

void autoCompleteData( )
checkPivotTable() protected method

Checks if the given table is a pivot table.

For simplicity, this method only deals with the case where the pivot contains two PK columns, each referencing a column in a different table.

array|boolean checkPivotTable$table )
$table
return array|boolean

The relevant foreign key constraint information if the table is a pivot table, or false if the table is not a pivot table.

generate() public method

void generate( )
generateClassName() protected method

Generates a class name from the specified table name.

string generateClassName$tableName )
$tableName string

The table name (which may contain schema prefix)

return string

The generated class name

generateLabels() public method

Generates the attribute labels for the specified table.

array generateLabels$table )
$table \yii\db\TableSchema

The table schema

return array

The generated attribute labels (name => label)

generateRelationLink() protected method

Generates the link parameter to be used in generating the relation declaration.

string generateRelationLink$refs )
$refs array

Reference constraint

return string

The generated link parameter.

generateRelationName() protected method

Generate a relation name for the specified table and a base name.

string generateRelationName$relations$className$table$key$multiple )
$relations array

The relations being generated currently.

$className string

The class name that will contain the relation declarations

$table \yii\db\TableSchema

The table schema

$key string

A base name that the relation name may be generated from

$multiple boolean

Whether this is a has-many relation

return string

The relation name

generateRelations() protected method

array generateRelations( )
return array

The generated relation declarations

generateRules() public method

Generates validation rules for the specified table.

array generateRules$table )
$table \yii\db\TableSchema

The table schema

return array

The generated validation rules

generateTableName() public method

Generates the table name by considering table prefix.

If $useTablePrefix is false, the table name will be returned without change.

string generateTableName$tableName )
$tableName string

The table name (which may contain schema prefix)

return string

The generated table name

getDbConnection() protected method

\yii\db\Connection getDbConnection( )
return \yii\db\Connection

The DB connection as specified by $db.

getDescription() public method

void getDescription( )
getName() public method

void getName( )
getTableNames() protected method

array getTableNames( )
return array

The table names that match the pattern specified by $tableName.

hints() public method

void hints( )
isColumnAutoIncremental() protected method

Checks if any of the specified columns is auto incremental.

boolean isColumnAutoIncremental$table$columns )
$table \yii\db\TableSchema

The table schema

$columns array

Columns to check for autoIncrement property

return boolean

Whether any of the specified columns is auto incremental.

requiredTemplates() public method

void requiredTemplates( )
rules() public method

void rules( )
stickyAttributes() public method

void stickyAttributes( )
validateDb() public method

Validates the $db attribute.

void validateDb( )
validateModelClass() public method

Validates the $modelClass attribute.

void validateModelClass( )
validateNamespace() public method

Validates the $ns attribute.

void validateNamespace( )
validateTableName() public method

Validates the $tableName attribute.

void validateTableName( )