mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-09 01:27:20 +08:00
Gii model generator did not add correct db connection
if component id is different from 'db'
This commit is contained in:
@ -41,6 +41,16 @@ class <?= $className ?> extends <?= '\\' . ltrim($generator->baseClass, '\\') .
|
||||
{
|
||||
return '<?= $tableName ?>';
|
||||
}
|
||||
<?php if ($generator->db !== 'db'): ?>
|
||||
|
||||
/**
|
||||
* @return \yii\db\Connection the database connection used by this AR class.
|
||||
*/
|
||||
public static function getDb()
|
||||
{
|
||||
return Yii::$app->get('<?= $generator->db ?>');
|
||||
}
|
||||
<?php endif; ?>
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
|
||||
Reference in New Issue
Block a user