change database before starting session

0

good afternoon the truth I hope you help me and thank you very much for any comments

in the main of yii the database is configured. but I would like to select which Database I want to enter without needing to go to main of yii how could I do it?

    
asked by Gilberto Asuaje 01.10.2016 в 20:05
source

1 answer

2

What you can do is add more databases in the yii main, then add a logic in case you use the login in your page that at the beginning of the session by a parameter determine which database to use,

It occurs to me to have a single database to validate the users and in it you can determine which connection to use, but in the main of yii 1.x it is required to add the connections.

   'db1' => array( //db de Calidad
        'connectionString' => 'mysql:host=localhost;dbname=db1',
        'emulatePrepare' => true,
        'username' => 'admin',
        'password' => 'admin',
        'charset' => 'utf8',
    ),
    'db2' => array( //db de Desarrollo
        'connectionString' => 'mysql:host=localhost;dbname=test',
        'emulatePrepare' => true,
        'username' => 'admin',
        'password' => 'admin',
        'charset' => 'utf8',
    ),

I hope it helps you.

Greetings.

    
answered by 17.10.2016 / 05:51
source