gpt4 book ai didi

php - UnixODBC 多个数据源不起作用

转载 作者:太空宇宙 更新时间:2023-11-04 04:19:17 27 4
gpt4 key购买 nike

我使用unixODBC连接到mssql数据库通过 odbc。问题是无论我添加多少数据源odbc.ini,它始终使用列表中的第一个数据库..

odbcinst.ini
[ODBC]
Trace = Yes
TraceFile = /tmp/sql.log
ForceTrace = Yes
Pooling = Yes
[SQLSERVER]
Description = SQLSERVER
Driver = /usr/local/freetds/lib/libtdsodbc.so
Setup = /usr/local/freetds/lib/libtds.so
CPTimeout = 5
CPReuse = 5
#FileUsage = 1

odbc.ini
[DNS1]
Driver = SQLSERVER
Description = SQLSERVER
Server = 192.168.1.10
Database = fr_boatsdata
Port = 2300
[INTERPOLICY]
Driver = SQLSERVER
Description = SQLSERVER
Server = 192.168.1.10
#Database = inter_policy
Port = 2300

我的代码:

@include(S_ROOT.'./source/lib/adodb5/adodb.inc.php');
$this->link = &ADONewConnection('odbc_mssql');
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
$dns="Driver={SQL Server};Server={$dbhost};Database={$connInfo['Database']};";
//$dns="DNS=INTERPOLICY";
@$this->link->Connect($dsn,$connInfo['UID'],$connInfo['PWD']);

最佳答案

有了 odbcinst,ini 我会尝试

$dns="Driver={SQLSERVER};服务器={$dbhost};数据库={$connInfo['Database']};";

或者

$dns="DSN=INTERPOLICY";

关于php - UnixODBC 多个数据源不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14576600/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com