Study the thinkphp framework for a few days, but never find out where to get the database configuration information when the database is instantiated
' Db_type ' = ' mysql ',
' db_host ' = ' localhost ',
' db_name ' = ' examples ',
' Db_user ' = ' root ',
' Db_pwd ' = ' 123456 ',
' Db_port ' = ' 3306 ',
' Db_prefix ' = ' think_ ',
Then, return the database instantiation object
Seeking expert analysis
Reply to discussion (solution)
Instantiate the Think class by invoking the C function in the Think::buildapp method to load
And remains in the C function as a static variable
$user =new Model ("user");//"User" is the database table name
$user =m ("user"); This is a simple way for thinkphp to do so.
$list = $user->select ();
Var_dump ($list);
Configuration is
config.inc.php File and
In the controller
$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);
Instantiate the Think class by invoking the C function in the Think::buildapp method to load
And remains in the C function as a static variable
This is what I want, doubts to solve, give points
Database configuration information not really config.inc.php inside? and the Think::buildapp () method loads the config.php file? I'm not connected to the database. What is the reason for the database configuration information inside the config.inc.php? Seek expert guidance
Just started to study thinkphp have to understand the exchange of gratitude, I QQ 907008876