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
3e3e4435
Commit
3e3e4435
authored
Apr 23, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored the fix for #3222.
parent
0480fcc2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
14 deletions
+17
-14
CHANGELOG.md
extensions/gii/CHANGELOG.md
+1
-0
Generator.php
extensions/gii/generators/model/Generator.php
+14
-13
model.php
extensions/gii/generators/model/default/model.php
+1
-1
CHANGELOG.md
framework/CHANGELOG.md
+1
-0
No files found.
extensions/gii/CHANGELOG.md
View file @
3e3e4435
...
...
@@ -6,6 +6,7 @@ Yii Framework 2 gii extension Change Log
-
Bug #1263: Fixed the issue that Gii and Debug modules might be affected by incompatible asset manager configuration (qiangxue)
-
Enh #3088: The gii module will manage their own URL rules now (qiangxue)
-
Enh #3222: Added
`useTablePrefix`
option to the model generator for Gii (horizons2)
2.0.0-beta April 13, 2014
...
...
extensions/gii/generators/model/Generator.php
View file @
3e3e4435
...
...
@@ -30,7 +30,7 @@ class Generator extends \yii\gii\Generator
public
$baseClass
=
'yii\db\ActiveRecord'
;
public
$generateRelations
=
true
;
public
$generateLabelsFromComments
=
false
;
public
$useTablePrefix
=
false
;
public
$useTablePrefix
=
false
;
/**
* @inheritdoc
...
...
@@ -536,23 +536,24 @@ class Generator extends \yii\gii\Generator
}
/**
* Generates a the tablename with tableprefix usage .
* @param string $tableName the table name (which may contain schema prefix)
* @return string the generated table name if useTablePrefix == true return with {{%}} depending of the position of the prefix
* Generates the table name by considering table prefix.
* If [[useTablePrefix]] is false, the table name will be returned without change.
* @param string $tableName the table name (which may contain schema prefix)
* @return string the generated table name
*/
public
function
generateTable
n
ame
(
$tableName
)
public
function
generateTable
N
ame
(
$tableName
)
{
if
(
!
$this
->
useTablePrefix
)
{
return
$tableName
;
}
else
{
$db
=
$this
->
getDbConnection
();
if
(
preg_match
(
"/^
{
$db
->
tablePrefix
}
(.*?)$/"
,
$tableName
,
$matches
))
{
$tableName
=
'{{%'
.
$matches
[
1
]
.
'}}'
;
}
elseif
(
preg_match
(
"/^(.*?)
{
$db
->
tablePrefix
}
$/"
,
$tableName
,
$matches
))
{
$tableName
=
'{{'
.
$matches
[
1
]
.
'%}}'
;
}
return
$tableName
;
}
$db
=
$this
->
getDbConnection
();
if
(
preg_match
(
"/^
{
$db
->
tablePrefix
}
(.*?)$/"
,
$tableName
,
$matches
))
{
$tableName
=
'{{%'
.
$matches
[
1
]
.
'}}'
;
}
elseif
(
preg_match
(
"/^(.*?)
{
$db
->
tablePrefix
}
$/"
,
$tableName
,
$matches
))
{
$tableName
=
'{{'
.
$matches
[
1
]
.
'%}}'
;
}
return
$tableName
;
}
/**
...
...
extensions/gii/generators/model/default/model.php
View file @
3e3e4435
...
...
@@ -39,7 +39,7 @@ class <?= $className ?> extends <?= '\\' . ltrim($generator->baseClass, '\\') .
*/
public static function tableName()
{
return '
<?=
$generator
->
generateTable
n
ame
(
$tableName
)
?>
';
return '
<?=
$generator
->
generateTable
N
ame
(
$tableName
)
?>
';
}
<?php
if
(
$generator
->
db
!==
'db'
)
:
?>
...
...
framework/CHANGELOG.md
View file @
3e3e4435
...
...
@@ -28,6 +28,7 @@ Yii Framework 2 Change Log
-
Enh #3108: Added
`yii\debug\Module::enableDebugLogs`
to disable logging debug logs by default (qiangxue)
-
Enh #3132:
`yii\rbac\PhpManager`
now supports more compact data file format (qiangxue)
-
Enh #3154: Added validation error display for
`GridView`
filters (ivan-kolmychek)
-
Enh #3222: Added
`useTablePrefix`
option to the model generator for Gii (horizons2)
-
Enh: Added support for using sub-queries when building a DB query with
`IN`
condition (qiangxue)
-
Enh: Supported adding a new response formatter without the need to reconfigure existing formatters (qiangxue)
-
Enh: Added
`yii\web\UrlManager::addRules()`
to simplify adding new URL rules (qiangxue)
...
...
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