В конфиге/**
* @var Connection|array|string the DB connection object or the application component ID of the DB connection.
* After the DbManager object is created, if you want to change this property, you should only assign it
* with a DB connection object.
* Starting from version 2.0.2, this can also be a configuration array for creating the object.
*/
public $db = 'db';
Код: Выделить всё
return [
'components' => [
'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=cg77777_db',
'username' => 'cg77777_db',
'password' => 'asdasd',
'charset' => 'utf8',
],
'dynamicServiceLocator' => [
'class' => 'general\components\DynamicServiceLocator',
'activeCity' => [
'class' => 'general\components\ActiveCity',
'default' => 0,
],
'components' => [
'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=cg77777_{city}',
'username' => 'cg77777_{city}',
'password' => '{password}',
'charset' => 'utf8',
],
],
],
],
];
Код: Выделить всё
'authManager' => [
'class' => 'general\components\myDbManager',
],
Код: Выделить всё
use yii\rbac\DbManager;
class myDbManager extends DbManager
{
public $db = ['dynamicServiceLocator']; <---- как сюда правильно передать текущее подключение?
}