Thinkphp3.1 connects to the database across databases. What should I do?

Source: Internet
Author: User
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.

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.