Where does thinkphp read the database configuration information in the Conf/conf. php file?
Source: Internet
Author: User
Where does thinkphp read Conf/conf. the database configuration information in the PHP file has been studied in thinkphp & nbsp; framework for several days, but the database configuration information obtained during Database instantiation cannot be found. & nbsp; & nbsp; 'DB _ type' = & gt; 'mysql', & nbsp; & n where thinkphp reads Conf/conf. database configuration information in the PHP file
I have been studying the thinkphp framework for a few days, but I still cannot find the database configuration information obtained when instantiating the database.
'Db _ type' => 'mysql ',
'Db _ host' => 'localhost ',
'Db _ name' => 'examples ',
'Db _ user' => 'root ',
'Db _ pwd' => '123 ',
'Db _ port' => '123 ',
'Db _ prefix' => 'think _',
Then, return the database instantiation object
Expert analysis
------ Solution --------------------
When instantiating the Think class, call the C function in the Think: buildApp method to load
It is stored in the C function as a static variable.
------ Solution --------------------
$ User = new Model ("User"); // "User" is the name of the database table.
$ User = M ("User"); this is a simple method provided by thinkphp.
$ List = $ user-> select ();
Var_dump ($ list );
Configuration is
Config. inc. php file and
In the controller
$ Arrr = array (
'Dbms '=> 'mysqli', // note that the key name in the group in this book cannot be changed.
'Username' => 'Google ',
'Password' => 'hello ',
'Hostname' => '2017. 0.0.1 ',
'Database' => 'mydbname ',
);
$ Db = new Db ($ arrr );
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.