这对你有帮助吗?
http://blog.nguyenvq.com/2010/05/16/freetds-unixodbc-rodbc-r/
我使用FreeTDS从Linux服务器连接到Microsoft SQL服务器,看起来上面链接中的人已经使用FreeTDS从Mac连接。
这是我的 /etc/freetds/freetds.conf 文件(我添加的唯一部分是在 XYZ 服务器的最后):
[global]
# TDS protocol version
; tds version = 4.2
# Whether to write a TDSDUMP file for diagnostic purposes
# (setting this to /tmp is insecure on a multi-user system)
; dump file = /tmp/freetds.log
; debug flags = 0xffff
# Command and connection timeouts
; timeout = 10
; connect timeout = 10
# If you get out-of-memory errors, it may mean that your client
# is trying to allocate a huge buffer for a TEXT field.
# Try setting 'text size' to a more reasonable limit
text size = 64512
# Define a connection to the MSSQL server.
[xyz]
host = xyz
port = 1433
tds version = 8.0
[由提问者编辑]
FreeTDS配置是答案的前半部分。配置完成后,您应该能够从命令行运行类似的东西并进行连接:
tsql -S xyz -U username -P password
然后,您需要使用 dblib,而不是 mssql 作为 PDO 驱动程序:
$pdo = new PDO("dblib:host=$dbhost;dbname=$dbname",
"$dbuser","$dbpwd");
其中 $dbhost 是 freetds.conf 文件中的名称