Gii model generator did not add correct db connection

if component id is different from 'db'
This commit is contained in:
Carsten Brandt
2014-04-14 10:17:01 +02:00
parent f4c38faf74
commit cd4b3f7827

View File

@ -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