Thinkphp3.1 connects to the database across databases. In the configuration file, the default homepage is to connect to mysql & nbsp; and then I add an array below: mssql configuration DB_MSSQL & nbsp; & gt; array (DB_CHARSET & gt; GBK2312, DB_TYPE & nbsp; & gt; & nbsp; mssql, Thinkphp3.1 cross-database connection to the database.
In the configuration file, the homepage is connected to mysql by default, and an array is added below:
// Mssql configuration
'Db _ mssql' => array (
// 'DB _ charset' => 'gbk2312 ',
'Db _ type' => 'mssql ',
'Db _ host' => '2017. 198.11.156 ',
'Db _ name' => 'Toot ',
'Db _ user' => 'sa ',
'Db _ pwd' => '123 ',
'Db _ port' => '123 ',
'Db _ prefix' => '',
),
Then
Public function index ()
{
$ User = M ('user', 'Toot ');
$ User-> db (1, 'Toot ');
$ Info = $ user-> select ()-> limit (10 );
Dump ($ info );
$ This-> display ();
}
Program error. unable to connect to database!
------ Solution --------------------
Is the parameter correct? Is the database remotely connected? Yes. is remote connection allowed?
First, paste the error message ........
------ Solution --------------------
How do I feel different from this description? ThinkPHP3.1 new features: comprehensive multi-database operations
------ Solution --------------------
Should I use the D function for connection?
Mssql does not have the DESCRIBE command and cannot automatically create a model.
------ Solution --------------------
Reference:
Quote: reference:
Is the parameter correct? Is the database remotely connected? Yes. is remote connection allowed?
First, paste the error message ........
[Error message]
No database configuration defined
Is this error message clear? The database configuration name does not exist.
$ User-> db (1, 'Toot'); this is a dynamic call. here, TOOT should be changed to the name DB_MSSQL in your configuration file.
------ Solution --------------------
If you are not familiar with TP, you will know what is going on with the breakpoint tracking program.