Thinkphp3.1 connects to the database across databases. 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!
Reply to discussion (solution)
Is the parameter correct? Is the database remotely connected? Yes. is remote connection allowed?
First, paste the error message ........
Allow remote connection. I can directly use php. (Error type: 500)
How do I feel different from this description? ThinkPHP3.1 new features: comprehensive multi-database operations
How do I feel different from this description? ThinkPHP3.1 new features: comprehensive multi-database operations
He described that two mysql databases can be connected if they are mysql. now, mssql cannot be connected.
How do I feel different from this description? ThinkPHP3.1 new features: comprehensive multi-database operations
According to his description $ User = M ('user', 'think _ ', 'DB _ config2 ');
My $ user = M ('user', '', 'Toot'); this should be fine for writing. my mssql table has no prefix.
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
Should I use the D function for connection?
Mssql does not have the DESCRIBE command and cannot automatically create a model.
I can use M to operate two mysql databases at the same time. Is there a problem with my mssql configuration?
Mssql directly uses php to implement Ctrip.
Mysql has the DESCRIBE command to automatically create a model, so there is no connection problem.
The DESCRIBE tbl_name command is used to obtain field information, similar
FieldTypeNullKeyDefaultExtra idvarbinary(20)NO moneybigint(20)NO0 flagchar(3)NO xvarchar(50)NO
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.
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.
Is changed to DB_MSSQL prompt: no database configuration is defined
Has someone connected mssql,
If you are not familiar with TP, you will know what is going on with the breakpoint tracking program.
Still not solved.