1、安装pdo_odbc扩展

参考php官方文档

http://php.net/manual/zh/ref.pdo-odbc.php

先安装unixODBC之类的包,然后编译pdo_odbc扩展

 

2、安装Microsoft ODBC Driver for SQL Server on Linux

参考微软官方文档

https://msdn.microsoft.com/en-us/library/hh568454(v=SQL.110).aspx

 

安装好后用下列代码测试

        $obj = new \PDO("odbc:Driver={ODBC Driver 13 for Sql Server};Server=111.111.111.111;Database=dbname;","dbuser","pwd");
        
        $sql = 'SELECT top 1 * from table';
        foreach ($obj->query($sql) as $row) {
            var_dump($row);
        
        }
        
        exit();

 

相关文章:

  • 2021-10-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-19
  • 2021-11-03
  • 2021-07-27
猜你喜欢
  • 2021-09-28
  • 2021-10-11
  • 2021-09-15
  • 2021-12-09
  • 2021-12-06
  • 2022-12-23
  • 2021-08-30
相关资源
相似解决方案