thinkphp where to read the database configuration information in the conf/conf.php file, how to handle

Source: Internet
Author: User
thinkphp where to read the database configuration information in the conf/conf.php file
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
------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

------Solution--------------------
$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);
  • Contact Us

    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.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.