Thinkphp3.1 connect the database across libraries.
In the configuration file, the default is to connect to MySQL and I added the following number of groups:
MSSQL Configuration
' Db_mssql ' =>array (
' Db_charset ' = ' GBK2312 ',
' Db_type ' = ' mssql ',
' Db_host ' = ' 152.198.11.156 ',
' Db_name ' = ' toot ',
' Db_user ' = ' sa ',
' Db_pwd ' = ' 123456 ',
' Db_port ' = ' 1433 ',
' Db_prefix ' = ',
),
And then in
Public Function Index ()
{
$user = M (' user ', ' toot ');
$user->db (1, ' toot ');
$info = $user->select ()->limit (10);
Dump ($info);
$this, display ();
}
Program error, not connected to the database!
-
--------Solution--------
-
Have you got the parameters? is the database remote connected? Yes, is it allowed to connect remotely?
Put out the error message first ...
-
--------Solution--------
-
Allow remote connection, I direct PHP is possible. (Error type: $)
-
--------Solution--------
-
How does it feel different from this description? ThinkPHP3.1 new features multi-database operation Improvement
-
--------Solution--------
- Reference to the 3 floor xuzuning's reply:
How does it feel different from this description ThinkPHP3.1 new feature multi-database operation Perfection
He's describing two MySQL. If it's MySQL, I can. To connect, now the MSSQL is not connected.
-
--------Solution--------
- Reference 3 Floor xuzuning's reply:
How does it feel different from this description? ThinkPHP3.1 new features multi-database operation Improvement
According to his description $User = M (' User ', ' think_ ', ' db_config2 ');
My $user= M (' user ', ' ', ' toot '), this should be OK, my MSSQL table does not have a prefix.
-
--------Solution--------
- Reference 1 Floor Novolee's reply: Have you
got the parameters? is the database remote connected? Yes, is it allowed to connect remotely?
Put out the error message first ...
[Error message]
No database configuration defined
-
--------Solution--------
-
Do you want to use the D function when connecting?
MSSQL does not have a DESCRIBE directive and should not automatically create models
-
--------Solution--------
-
I use M is can operate two MySQL at the same time, is not my MSSQL configuration have a problem?
MSSQL Direct PHP can be Ctrip
-
-
--------Solution--------
-
MySQL has DESCRIBE instruction, can create the model automatically, so there is no connection problem
The function of the DESCRIBE tbl_name directive is to get field information, similar to plain Text code ?
12345 |
field type Null key default extra id varbinary no money bigint no 0 flag char (3) no x varchar no |
-
--------Solution--------
-
Quote: Reference 1 Novolee reply:
is the parameter right? is the database remote connected? Yes, is it allowed to connect remotely?
Paste the error message first ...
[ error message ]
No database configuration is defined
Looking at this error message, isn't it clear? The database configuration name does not exist.
$user->db (1, ' toot '); This is a dynamic call, where Toot should be changed to the name in your config file Db_mssql
-
--------Solution--------
- Reference 10 Floor Novolee's reply:
Quote: Referring to the reply of the 6 floor YXQC:
Quote: Referring to the reply of the 1 floor Novolee:
Have you got the parameters? is the database remote connected? Yes, is it allowed to connect remotely?
Put out the error message first ...
[Error message]
No database configuration defined
Isn't it clear that this is the wrong message? The database configuration name does not exist.
$user->db (1, ' toot '); This is a dynamic call, and the toot here should be changed to the name in your config file db_mssql
is to change to DB_MSSQL hint: No database configuration defined
-
--------Solution--------
-
has anyone connected to MSSQL?
-
--------Solution--------
-
TP is unfamiliar, you can trace the breakpoint under the program to know what's going on.
-
--------Solution--------
-
It's still not settled.
Thinkphp3.1 connect the database across libraries.