Search code examples
phpsql-serverzend-frameworkdoctrine

Doctrine on linux: unable to connect to sql server


I am trying to run a zend + doctrine web application from a Debian 9 host, using php 5.6

I've the need to connect to a sql server that is on different host (it's a windows machine, obviously)

I tested connection using isql command line and I am correctly able to login and to operate in the desired db

The problem is that the webabb do not return me any error but simply fails to login (i am not the developer of this webapp).

Configuration follows:

odbcinst.ini

[FreeTds]
Description = MS SQL database access with Free TDS
Driver      = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
Setup       = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so
UsageCount  = 1
Trace       = Yes
TraceFile   = /tmp/odbcinst.log

freetds.ini

host ip is exact, I removed when pasting here

[flower1]
 host = xxx.xxx.xxx.xxx
 port = 1433
 tds version = 7.3

odbc.ini

[test_flower1]
Description=Test for MSSQL Server on flower1
Driver=FreeTds
Database=test_flower1
ServerName=flower1
TDS_Version=7.3

application.ini

;; Database
doctrine.dsn = "odbc:Driver={Sql_server};Server=flower1;Database=test_flower1;Uid=<redacted but correct>;Pwd=<redacted but correct>;"

How can I debug the source of the problem?

I've not previously experience with zend/doctrine


Solution

  • The problem was due to this

    doctrine.dsn = "odbc:Driver={Sql_server};Server=flower1;Database=test_flower1;Uid=<redacted but correct>;Pwd=<redacted but correct>;"
    

    I solved simply adding the port !

    doctrine.dsn = "odbc:Driver={Sql_server};Server=flower1;Port=1433;Database=test_flower1;Uid=<redacted but correct>;Pwd=<redacted but correct>;"