mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-12 20:21:19 +08:00
Fixes #916: generation of class name from table name has problem.
This commit is contained in:
@@ -514,7 +514,8 @@ class Generator extends \yii\gii\Generator
|
|||||||
$patterns[] = '/^' . str_replace('*', '(\w+)', $pattern) . '$/';
|
$patterns[] = '/^' . str_replace('*', '(\w+)', $pattern) . '$/';
|
||||||
}
|
}
|
||||||
if (!empty($db->tablePrefix)) {
|
if (!empty($db->tablePrefix)) {
|
||||||
$patterns[] = "/^{$db->tablePrefix}(.*?)|(.*?){$db->tablePrefix}$/";
|
$patterns[] = "/^{$db->tablePrefix}(.*?)$/";
|
||||||
|
$patterns[] = "/^(.*?){$db->tablePrefix}$/";
|
||||||
} else {
|
} else {
|
||||||
$patterns[] = "/^tbl_(.*?)$/";
|
$patterns[] = "/^tbl_(.*?)$/";
|
||||||
}
|
}
|
||||||
@@ -523,6 +524,7 @@ class Generator extends \yii\gii\Generator
|
|||||||
foreach ($patterns as $pattern) {
|
foreach ($patterns as $pattern) {
|
||||||
if (preg_match($pattern, $tableName, $matches)) {
|
if (preg_match($pattern, $tableName, $matches)) {
|
||||||
$className = $matches[1];
|
$className = $matches[1];
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $this->_classNames[$tableName] = Inflector::id2camel($className, '_');
|
return $this->_classNames[$tableName] = Inflector::id2camel($className, '_');
|
||||||
|
|||||||
Reference in New Issue
Block a user