我想使用PDO使用PHP pdo_dblib
连接到Sybase。这就是我所做的:
$conn = new PDO("dblib:host=$db_host:$db_port;dbname=$db_name","$login","$password");
它显示了我SQL Null error
。我不知道如何做对。我检查了php信息,pdo_dblib就在那里。
PDO Driver for FreeTDS/Sybase DB-lib: Flavour
enabled: freetds
<顺便说一下,是否需要数据库端口?在此之前,我没有输入数据库端口号,现在我仍然无法获取端口号。
答案 0 :(得分:2)
按照以下步骤查找错误原因
步骤1:使用telnet连接。
xxx@ubuntuvbox:~$ telnet 10.1.1.1 5000
Trying 10.1.1.1...
Connected to 10.1.1.1.
第2步:配置FreeTDS
编辑freetds.conf,位于/ etc / freetds /(Ubuntu 11.10)
[global]
# TDS protocol version
tds version = 5.0
text size = 64512
步骤3:使用FreeTDS进行连接
xxx@ubuntuvbox:~$ sqsh -S 10.1.1.1:5000 -Usa
sqsh-2.1 Copyright (C) 1995-2001 Scott C. Gray
This is free software with ABSOLUTELY NO WARRANTY
For more information type '\warranty'
Password:
Msg 2401, Level 11, State 2
Server 'XXXXXX'
Character set conversion is not available between client character set 'utf8'
and server character set 'cp850'.
No conversions will be done.
1> select * from .....
步骤4:使用FreeTDS与PHP连接
检查一下......
$dbh = new PDO ('dblib:host=10.1.1.1:5000;dbname=databasename','sa','password');