From 38c0b197f9a10c9caec82dd4de194002f8219fa2 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Thu, 3 Oct 2013 11:01:52 -0400 Subject: [PATCH] Fixes #916: generation of class name from table name has problem. --- framework/yii/gii/generators/model/Generator.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/framework/yii/gii/generators/model/Generator.php b/framework/yii/gii/generators/model/Generator.php index 7fba83f..69edb5f 100644 --- a/framework/yii/gii/generators/model/Generator.php +++ b/framework/yii/gii/generators/model/Generator.php @@ -514,7 +514,8 @@ class Generator extends \yii\gii\Generator $patterns[] = '/^' . str_replace('*', '(\w+)', $pattern) . '$/'; } if (!empty($db->tablePrefix)) { - $patterns[] = "/^{$db->tablePrefix}(.*?)|(.*?){$db->tablePrefix}$/"; + $patterns[] = "/^{$db->tablePrefix}(.*?)$/"; + $patterns[] = "/^(.*?){$db->tablePrefix}$/"; } else { $patterns[] = "/^tbl_(.*?)$/"; } @@ -523,6 +524,7 @@ class Generator extends \yii\gii\Generator foreach ($patterns as $pattern) { if (preg_match($pattern, $tableName, $matches)) { $className = $matches[1]; + break; } } return $this->_classNames[$tableName] = Inflector::id2camel($className, '_');