I am trying to connect to an Azure SQL database through PHP running on a Ubuntu 11.04 server.
The server runs PHP Version => 5.3.5-1ubuntu7.11.
I installed freetds-bin, freetds-common, tdsodbc, odbcinst, php5-odbc and unixodbc using apt-get install several times. I tried to compile FreeTDS with SSL support, but I'm not sure if it was successful.
At this moment, I get the error message "08S01 - Communication Error" when I try to connect using the isql tool. A Microsoft article explains this error as follows: "The connection between the driver and the data source that the driver was trying to connect to did not complete before the SQLDriverConnect function was completed." Some research on this issue indicates a lack of SSL support in FreeTDS, but I don’t know how to verify what was included.
I will use either PHP Data Objects or mssql_ * to connect to Azure SQL Database. I am less familiar with PDO, but it seems that PDO does not necessarily use ODBC? I don’t quite understand this, and I suspect that it led me to resolve issues observed with isql that are not related to the problems that I see in PHP. Are connection problems using the isql tool related to connection problems in PDO or mssql_ * functions in PHP?
My last attempt using PDO:
<?php
$c = new PDO("odbc:Driver=FreeTDS;Port=1433;Server=sssssssssss.database.windows.net;Database=db_xxxxx_xxx_xxx;UID=db_xxxxx_xxx_xxx_ExternalWriter;PWD=ppppppppp");
?>
This code generates the following errors in my Apache log file:
[ 24 13:23:10 2013] [] [ 10.1.1.11] PHP : "PDOException" "SQLSTATE [08S01] SQLDriverConnect: 20004 [unixODBC] [FreeTDS] [SQL Server] server failed" /var/www/test/pdo.php:3\nStack trace:\n # 0 /var/www/test/pdo.php(3): PDO → __ construct ('odbc: Driver = Fre...')\n # 1 {main}\n /var/www/test/pdo.php 3
/etc/freetds/freetds.conf:
[global]
tds version = 9.1
dump file = /tmp/freetds.log
debug flags = 0xffff
; timeout = 10
; connect timeout = 10
text size = 64512
[FreeTDS]
host = ssssssssss.database.windows.net
port = 1433
tds version = 9.1
client charset = UTF-8
/etc/odbc.ini:
[TS]
Description = "test"
Driver = FreeTDS
Server = sssssssssssss.database.windows.net
Port = 1433
Database = db_xxxxxxx_xxx_xxx
/etc/odbcinst.ini
[FreeTDS]
Description = tdsodbc
Driver = /usr/lib/odbc/libtdsodbc.so
. . !