How to configure Doctrine DBAL multidatabase or multiple connections in YII?

Clash Royale CLAN TAG#URR8PPPHow to configure Doctrine DBAL multidatabase or multiple connections in YII?
I have a two databases, in first database i use sqlanywhere, but I don't know how to get multipleconnection doctrine/DBAL in yii.
Please help
this is first database with sqlanywhere
'dbmain'=>[
'class'=>'apicomponentsdoctrineDoctrineDBAL',
'dbalConfig'=>[
'driver' => 'sqlanywhere',
'host' => '192.168.0.1',
'port' => 36,
'server' => '',
'user' => 'dba',
'password' => '123456'
]
],
i want to use mysql connection like this but still get error
'dbsecond'=>[
'class'=>'apicomponentsdoctrineDoctrineDBAL',
'dbalConfig'=>[
'driver' => 'mysql',
'host' => '172.16.1.1',
'port' => 3306,
'server' => '',
'user' => 'guest',
'password' => '123456'
]
public $dbalConfig='dbalConfig';
public function init(){
parent::init();
$this->conn = DriverManager::getConnection($config=$this->dbalConfig);
}
public function getConnection(){
return $this->conn;
}
}
this is base model
class BaseModel extends Model{
protected $conn;
protected $queryBuilder;
public function init()
{
parent::init();
$this->conn=Yii::$app->dbmain->getConnection();
$this->queryBuilder = $this->conn->createQueryBuilder();
//teskoneksi kedua
}
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.