mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-20 08:27:21 +08:00
Merge pull request #2135 from thiagotalma/master
Ensure that the table prefix is used when generating the class name.
This commit is contained in:
@@ -543,6 +543,8 @@ class Generator extends \yii\gii\Generator
|
|||||||
|
|
||||||
$db = $this->getDbConnection();
|
$db = $this->getDbConnection();
|
||||||
$patterns = [];
|
$patterns = [];
|
||||||
|
$patterns[] = "/^{$db->tablePrefix}(.*?)$/";
|
||||||
|
$patterns[] = "/^(.*?){$db->tablePrefix}$/";
|
||||||
if (strpos($this->tableName, '*') !== false) {
|
if (strpos($this->tableName, '*') !== false) {
|
||||||
$pattern = $this->tableName;
|
$pattern = $this->tableName;
|
||||||
if (($pos = strrpos($pattern, '.')) !== false) {
|
if (($pos = strrpos($pattern, '.')) !== false) {
|
||||||
@@ -550,8 +552,6 @@ class Generator extends \yii\gii\Generator
|
|||||||
}
|
}
|
||||||
$patterns[] = '/^' . str_replace('*', '(\w+)', $pattern) . '$/';
|
$patterns[] = '/^' . str_replace('*', '(\w+)', $pattern) . '$/';
|
||||||
}
|
}
|
||||||
$patterns[] = "/^{$db->tablePrefix}(.*?)$/";
|
|
||||||
$patterns[] = "/^(.*?){$db->tablePrefix}$/";
|
|
||||||
$className = $tableName;
|
$className = $tableName;
|
||||||
foreach ($patterns as $pattern) {
|
foreach ($patterns as $pattern) {
|
||||||
if (preg_match($pattern, $tableName, $matches)) {
|
if (preg_match($pattern, $tableName, $matches)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user