简体   繁体   中英

MsSql/odbc driver now showing when set up on Ubuntu(Linux)

I have been trying to get MsSQL recognised on my linux based web server which currently has Ubuntu installed on it. I have followed the steps shown on this post but i have not managed to get it to work:

Connect PHP to MSSQL via PDO ODBC

Everytime i run the following command in PHP i simply ohly get mysql as though it only picks up the mysql.so file:

 foreach (PDO::getAvailableDrivers() as $driver)
    {
        echo $driver . '<br />';
    }

Does anybody know how i can get it to output the odbc driver also? The reason i ask is because the PHP application i am trying to run has the following code in it which i am trying to get around as it's written for Microsoft Server by the looks of it:

    if (extension_loaded('pdo_sqlsrv')) $this->extension = 'pdo_sqlsrv';
    else if (extension_loaded('pdo_odbc')) $this->extension = 'pdo_odbc';

If i comment the above code out the pdo statement doesn't connect for the reason i mentioned above due to no odbc driver

I tried to install freetds and configure it but i couldn't get it working as odbc doesn't show in the drivers list;

Reading package lists... Done Building dependency tree Reading state information... Done tdsodbc is already the newest version. unixodbc is already the newest version. 0 to upgrade, 0 to newly install, 0 to remove and 171 not to upgrade.

anybody got any suggestions on reading from MsSQL with PHP 5.4 on linux (Ubtuntu)?

Ok so i managed to get a stage further. I got the ODBC linux driver working and now i have hit another problem: SQLSTATE[08001] SQLDriverConnect: 0 [unixODBC][FreeTDS][SQL Server]Unable to connect to data source <---does this mean that the port needs to be forwarded or that the username and password i have is incorrect? I assume this means that the driver is ok? when i try a tsql it just seems to time out after 60 seconds

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM