php - 如何使用 ODBC+FreeTDS 从 UNIX 中的 PHP 连接到 sybase?

标签 php linux odbc sybase freetds

我尝试使用 FreeTDS 从终端连接 sybase,它工作正常,但我无法使用 PHP 连接数据库。

我已经对以下文件进行了更改。

/etc/odbc.ini 文件:

Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so
Server = 
Port = 
Database = 
Username = 
Password = 

freetds.conf 文件

[sybase]
    host=
    port=
    Tds version=5.0

使用终端可以正常工作

tsql -S SYBASE -U username -P password

但是从 PHP 连接我得到错误:

[unixODBC][Driver Manager]Data source name not found, and no default driver specified

PHP文件代码:

$db = ADONewConnection('odbc');

$DSN ='UID=username;PWD=password;EngineName=dbServiceName;AutoStop=No;Integrated=No;Debug=No;DisableMultiRowFetch=No;CommLinks=SharedMemory,TCPIP{};Compress=No;Driver={FreeTDS}';

$db->Connect($DSN );

最佳答案

我知道在某些版本中,您需要使用服务器的 IP 而不是名称,就像在 freetds.conf 中这样:

[myserver]
    host = 10.10.10.10
    port = 5000
    tds version = 5.0

我也不知道tds version是否区分大小写,但我一直看到它是小写的。您确定 PHP 正在读取与命令行版本相同的 freetds.conf 吗?

关于php - 如何使用 ODBC+FreeTDS 从 UNIX 中的 PHP 连接到 sybase?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39952999/

相关文章:

javascript - 如何使用ajax方法交叉检查数据库中是否存在数据?

linux - Squid3 在工作时间封锁网站

mysql - IIS7 ASP经典Mysql和ODBC驱动问题

postgresql - Postgres ODBC 驱动模块

vb6 - [Microsoft][ODBC 驱动程序管理器] 驱动程序的 SQLSetConnectAttr 失败 vb6

PHP 在远程网页中搜索字符串

php - 覆盖窗口 = onload

php - 无法将 stdClass 类型的对象用作数组 - JSON

linux - 建立相互依赖的共享库(Linux)

linux - 提取带有各种分隔符的文本的字符串号