Because all applications (projects) of the entire site need to be connected to the database, they should be set up separately in each project's configuration file. In the future if the database connection information has been modified, you have to modify the configuration file one, so it is not suitable for lazy people. Because the near-ink note that thinkphp's project configuration file is in array form, we can solve this problem by merging arrays. First, create a new config.inc.php file at the root of the Web site and write the database configuration parameters to the array
<?phpreturn Array (' db_type ' = ' mysql ', ' db_host ' = ' localhost ', ' db_name ' = ' oa ', ' db_user ' = ' root ', ' Db_pwd ' = = ', ' db_port ' = ' 3306 ', ' db_prefix ' = ' think_ ', ' show_page_trace ' = true,];? >
Then to the Project Profile conf/config.php, merge the personalization configuration with the public configuration parameters and return the array
$config _arr1 = include ('./config.inc.php '); $config _arr2 = Array (' site_name ' = ' site name ', ' site_title ' = ' website title ', ' Site_url ' + ' website link ', '); return Array_merge ($config _arr1, $config _arr2);
Then use C (' own defined name ') in the project to invoke the information of the merged configuration file
thinkphp configuration database connection common file and project personalization configuration Merge