When I connect to a database using the thinkphp framework, it will never be connected. The Code is as follows: config. php {code ...} then access the database through methods in the class. The USER is the database name publicfunctiontest () {code ...} when I connect to a database using the thinkphp framework, it will never be connected.
The Code is as follows:
Config. php
Return array (// 'config maps '=> 'configuration value' // static MODULE Access // 'module _ DENY_LIST' => array ('common', 'runtime ', 'admin'), // allow access // 'module _ ALLOW_LIST '=> array ('home', 'admin '), // The default loading module 'db _ type' => 'mysql', 'db _ host' => 'localhost: 8080 ', 'db _ user' => 'root ', 'db _ pwd' => '000000', 'db _ port' => '000000', 'db _ name' => 'thinkphp ', 'db _ prefix' => 'think _',);
Then access the database through methods in the class. The USER is the name of the database.
Public function test (){
$ User = new Model ('user'); // connection to the database var_dump ($ User-> select ();} He is always unsuccessful. Why.
Reply content:
When I connect to a database using the thinkphp framework, it will never be connected.
The Code is as follows:
Config. php
Return array (// 'config maps '=> 'configuration value' // static MODULE Access // 'module _ DENY_LIST' => array ('common', 'runtime ', 'admin'), // allow access // 'module _ ALLOW_LIST '=> array ('home', 'admin '), // The default loading module 'db _ type' => 'mysql', 'db _ host' => 'localhost: 8080 ', 'db _ user' => 'root ', 'db _ pwd' => '000000', 'db _ port' => '000000', 'db _ name' => 'thinkphp ', 'db _ prefix' => 'think _',);
Then access the database through methods in the class. The USER is the name of the database.
Public function test (){
$ User = new Model ('user'); // connection to the database var_dump ($ User-> select ();} He is always unsuccessful. Why.
Configuration'DB_HOST'=>'localhost:8080'
Remove Port
Only the address is entered in DB_HOST. You should not understand the role of the configuration file. The remaining ports are configured by default or special by DB_PORT,
Even if an error occurs, you can use M ()-> getError () to obtain the error message.