mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-09 09:47:25 +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 ?>';
|
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
|
* @inheritdoc
|
||||||
|
|||||||
Reference in New Issue
Block a user