I am new to use YII. In YII I need to create db connection when user fill form for example in a form I require these fields from user for db connection:
Host: Port: Username: Password: Dababase name:
When user click on connect with database. Then I need to create connection with database and load the Entered database tables.
You can use the input for create dinamically the connection
$connection = new \yii\db\Connection([
'dsn' => $dsn,
'username' => $username,
'password' => $password,
]);
see this guide for more http://www.yiiframework.com/doc-2.0/yii-db-connection.html and http://www.yiiframework.com/doc-2.0/guide-start-databases.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.