Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $connection = new CDbConnection($dsn, $username, $password);
- $connection->active = true;
- Yii::app()->setComponent('clientDB', $connection);
- 'db'=>array(
- 'connectionString' => 'mysql:host=hostIP;port=3306;dbname=database1',
- 'class'=>'CDbConnection',
- 'emulatePrepare' => true,
- 'username' => 'username1',
- 'password' => 'password1',
- 'charset' => 'utf8',
- ),
- 'db2'=>array(
- 'connectionString' => 'mysql:host=hostIP2;port=3306;dbname=database2',
- 'class'=>'CDbConnection',
- 'emulatePrepare' => true,
- 'username' => 'username2',
- 'password' => 'password2',
- 'charset' => 'utf8',
- ),
- $connection->Yii::app()->db2;
- //then you would pass the connection into whatever you are using for your queries.
- //For example for an raw SQL command:
- $command=$connection->createCommand($sqlQuery);
- $command->execute();
Add Comment
Please, Sign In to add comment