Home > PHP Framework > YII > body text

Can yii2 connect to db2?

(*-*)浩
Release: 2019-12-14 10:56:25
Original
2137 people have browsed it

Can yii2 connect to db2?

A project will require connecting to multiple databases as needed. The operation process in the actual project is recorded here. Including the configuration of database connection and how to generate model files and use them in the controller. (Recommended learning: yii framework)

Configuration

Open the database configuration file common\config\main-local.php, in Add db2 under the original db configuration item (the name can be chosen by yourself and cannot be repeated with other database names), and configure the properties of the second database

Can yii2 connect to db2?

The above configuration can complete the function of yii2 connecting to multiple databases, but you still need to pay attention to the actual application

Generate the model through gii, what needs to be paid attention to here is the database connection ID To change to db2 (fill in the English name of the second database library you set in main_local)

Can yii2 connect to db2?

The above is the detailed content of Can yii2 connect to db2?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template