Commit c43aa301 by Qiang Xue

Merge pull request #2135 from thiagotalma/master

Ensure that the table prefix is used when generating the class name.
parents b5b18daf d92a2353
......@@ -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)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment