dsymx68408 2016-01-08 09:52
浏览 52

哪个.so文件可以用于linux系统对应windows中的.dll文件,将php连接到ms sql server

I have used php5ts.dll files for php and ms sql server connection on my windows sytem but i need to do same for linux but same dll files do not work on linux as they are for windows. After Rnd I came to know that corresponding to dll files in windows we need .so files in linux SO question. I don't have knowledge that what excatly these .dll files do in php to connect it to ms sql server.

It would be great if some one help me understanding that why same does not work for linux and what could be the solution?

I also came through one same question here where user has asked similar question for windows instead of linux.

Following is the piece of code we use to create connection:

  • db.driver = "pdo_sqlsrv"
  • db.host = ""
  • db.dbname = ""
  • db.user = ""
  • db.password = ""

and driver files are placed here at D:\wamp\bin\php\php5.4.16 >>php5ts.dll and D:\wamp\bin\php\php5.4.16\ext >> php_sqlsrv_54_ts.dll

  • 写回答

1条回答 默认 最新

  • dongqing314511 2016-02-03 13:31
    关注

    To connect from php5 on a linux machine to Micrsoft SQL is a little couter intuitive, you actually need to use the sybase extension and the pear MDB2 driver for MS SQL. The MSSQL functions in PHP5 actually alias the Sybase functions if you can't install the MSSQL extension due to OS limitations.

    To solve this use the following commands...

    sudo apt-get install php5-sybase
    pear install --nodeps MDB2_Driver_mssql
    

    After doing that you can test it using...

    <?php
    
    $server = 'servername';
    $username = 'sa';
    $password = 'password';
    $database = 'xxx';
    $connection = mssql_connect($server, $username, $password);
    
    if($connection != FALSE)
    {
    echo "Connected to the database server OK<br />";
    }
    else
    {
    die("Couldn't connect");
    }
    
    if(mssql_select_db($database, $connection))
    {
    echo "Selected $database ok<br />";
    }
    else
    {
    die('Failed to select DB');
    }
    
    $query_result = mssql_query('SELECT @@VERSION');
    $row = mssql_fetch_array($query_result);
    
    if($row != FALSE)
    {
    echo "Version is {$row[0]}<br />";
    }
    mssql_free_result($query_result);
    mssql_close($connection);
    
    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料