Class yii\gii\generators\model\Generator
Inheritance | yii\gii\generators\model\Generator » yii\gii\Generator |
---|---|
Subclasses | hscstudio\heart\modules\gii\model\Generator |
Available since version | 2.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.
Public Properties
Protected Properties
Property | Type | Description | Defined By |
---|---|---|---|
$classNames | yii\gii\generators\model\Generator | ||
$tableNames | yii\gii\generators\model\Generator |
Public Methods
Protected Methods
Method | Description | Defined 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
Method Details
void attributeLabels( ) |
void autoCompleteData( ) |
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. |
---|
void generate( ) |
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 |
---|
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) |
---|
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. |
---|
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 |
---|
array generateRelations( ) | ||
return | array | The generated relation declarations |
---|
Generates validation rules for the specified table.
array generateRules( $table ) | ||
$table | \yii\db\TableSchema | The table schema |
return | array | The generated validation rules |
---|
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 |
---|
\yii\db\Connection getDbConnection( ) | ||
return | \yii\db\Connection | The DB connection as specified by $db. |
---|
void getDescription( ) |
void getName( ) |
array getTableNames( ) | ||
return | array | The table names that match the pattern specified by $tableName. |
---|
void hints( ) |
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. |
---|
void requiredTemplates( ) |
void rules( ) |
void stickyAttributes( ) |
Validates the $db attribute.
void validateDb( ) |
Validates the $modelClass attribute.
void validateModelClass( ) |
Validates the $ns attribute.
void validateNamespace( ) |
Validates the $tableName attribute.
void validateTableName( ) |