Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
7150524e
Commit
7150524e
authored
Aug 25, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finished model generator.
parent
b968402e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
16 deletions
+24
-16
Schema.php
framework/yii/db/Schema.php
+2
-2
Generator.php
framework/yii/gii/generators/model/Generator.php
+0
-0
model.php
framework/yii/gii/generators/model/templates/model.php
+22
-14
No files found.
framework/yii/db/Schema.php
View file @
7150524e
...
...
@@ -138,7 +138,7 @@ abstract class Schema extends Object
* @param string $schema the schema of the tables. Defaults to empty string, meaning the current or default schema name.
* @param boolean $refresh whether to fetch the latest available table schemas. If this is false,
* cached data may be returned if available.
* @return
array
the metadata for all tables in the database.
* @return
TableSchema[]
the metadata for all tables in the database.
* Each array element is an instance of [[TableSchema]] or its child class.
*/
public
function
getTableSchemas
(
$schema
=
''
,
$refresh
=
false
)
...
...
@@ -161,7 +161,7 @@ abstract class Schema extends Object
* If not empty, the returned table names will be prefixed with the schema name.
* @param boolean $refresh whether to fetch the latest available table names. If this is false,
* table names fetched previously (if available) will be returned.
* @return
array
all table names in the database.
* @return
string[]
all table names in the database.
*/
public
function
getTableNames
(
$schema
=
''
,
$refresh
=
false
)
{
...
...
framework/yii/gii/generators/model/Generator.php
View file @
7150524e
This diff is collapsed.
Click to expand it.
framework/yii/gii/generators/model/templates/model.php
View file @
7150524e
...
...
@@ -4,18 +4,12 @@
*
* @var yii\base\View $this
* @var yii\gii\generators\model\Generator $generator
* @var string $tableName
* @var string $className
* @var string $tableName
full table name
* @var string $className
class name
* @var yii\db\TableSchema $tableSchema
* @var string[] $labels
* @var string[] $rules
*
* - $tableName: the table name for this class (prefix is already removed if necessary)
* - $modelClass: the model class name
* - $tableSchema: list of table columns (name=>CDbColumnSchema)
* - $labels: list of attribute labels (name=>label)
* - $rules: list of validation rules
* - $relations: list of relations (name=>relation declaration)
* @var string[] $labels list of attribute labels (name=>label)
* @var string[] $rules list of validation rules
* @var array $relations list of relations (name=>relation declaration)
*/
echo
"<?php
\n
"
;
...
...
@@ -26,18 +20,22 @@ namespace <?php echo $generator->ns; ?>;
/**
* This is the model class for table "
<?php
echo
$tableName
;
?>
".
*
* Attributes:
*
<?php
foreach
(
$tableSchema
->
columns
as
$column
)
:
?>
* @property
<?php
echo
"
{
$column
->
phpType
}
\$
{
$column
->
name
}
\n
"
;
?>
<?php
endforeach
;
?>
<?php
if
(
!
empty
(
$relations
))
:
?>
*
<?php
foreach
(
$relations
as
$name
=>
$relation
)
:
?>
* @property
<?php
echo
$relation
[
1
]
.
(
$relation
[
2
]
?
'[]'
:
''
)
.
' $'
.
lcfirst
(
$name
)
.
"
\n
"
;
?>
<?php
endforeach
;
?>
<?php
endif
;
?>
*/
class
<?php
echo
$className
;
?>
extends
<?php
echo
'\\'
.
ltrim
(
$generator
->
baseClass
,
'\\'
)
.
"
\n
"
;
?>
{
/**
* @inheritdoc
*/
public function tableName()
public
static
function tableName()
{
return '
<?php
echo
$tableName
;
?>
';
}
...
...
@@ -61,4 +59,14 @@ class <?php echo $className; ?> extends <?php echo '\\' . ltrim($generator->base
<?php
endforeach
;
?>
);
}
<?php
foreach
(
$relations
as
$name
=>
$relation
)
:
?>
/**
* @return \yii\db\ActiveRelation
*/
public function get
<?php
echo
$name
;
?>
()
{
<?php
echo
$relation
[
0
]
.
"
\n
"
;
?>
}
<?php
endforeach
;
?>
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment