thinkphp Configuration Connection Database tips, thinkphp database tips
In this paper, we describe the common methods of thinkphp Configuration connection database, and share them for your reference. Here's how:
1. Add database configuration information to config.inc.php in the same directory as the thinkphp portal file
Copy the Code code as follows: <?php
Return Array (
' Db_type ' = ' mysqli ',
' db_host ' = ' localhost ',
' Db_name ' + ' demo ',
' Db_user ' = ' root ',
' Db_pwd ' = ' root ',
' Db_prefix ' = ' think_ ',
);
?>
Then add the following code to the config.php file in the project directory:
Copy the Code code as follows: <?php
$arr 1=array (
' Config item ' = ' config value '
' Url_model ' =>2,
' App_debug ' =>true,
' Log_record ' =>true,
......
);
$arr 2=include ' config.inc.php ';
Return Array_merge ($arr 1, $arr 2);
?>
In the background file can also be added as the code, so that after the database configuration of the connection information changes, only need to modify the information in the config.inc.php file can be achieved at the same time to modify the foreground and background database connection configuration information.
2. If you want to connect to another database in the controller , you can do so by adding the following code:
Copy the Code code as follows: $arrr =array (
' DBMS ' = ' mysqli ',//Note that the key names in this book group are not subject to change.
' username ' = ' Google ',
' Password ' = ' Hello ',
' Hostname ' = ' 127.0.0.1 ',
' Database ' = ' mydbname ',
);
$DB =new db ($ARRR);
It is hoped that this article will be helpful to everyone's thinkphp framework design.
http://www.bkjia.com/PHPjc/920609.html www.bkjia.com true http://www.bkjia.com/PHPjc/920609.html techarticle thinkphp Configuration Connection Database tips, thinkphp Database Tips This paper describes the thinkphp Configuration connection database common methods, share to everyone for your reference. The specific method is as follows: ...