mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-20 16:38:22 +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();
|
||||
$patterns = [];
|
||||
$patterns[] = "/^{$db->tablePrefix}(.*?)$/";
|
||||
$patterns[] = "/^(.*?){$db->tablePrefix}$/";
|
||||
if (strpos($this->tableName, '*') !== false) {
|
||||
$pattern = $this->tableName;
|
||||
if (($pos = strrpos($pattern, '.')) !== false) {
|
||||
@@ -550,8 +552,6 @@ class Generator extends \yii\gii\Generator
|
||||
}
|
||||
$patterns[] = '/^' . str_replace('*', '(\w+)', $pattern) . '$/';
|
||||
}
|
||||
$patterns[] = "/^{$db->tablePrefix}(.*?)$/";
|
||||
$patterns[] = "/^(.*?){$db->tablePrefix}$/";
|
||||
$className = $tableName;
|
||||
foreach ($patterns as $pattern) {
|
||||
if (preg_match($pattern, $tableName, $matches)) {
|
||||
|
||||
Reference in New Issue
Block a user