dongqing904999 2015-05-04 15:38
浏览 10

将Silex连接到MSSQL Server

Does anyone know how to connect a Silex based Web Application to a MSSQL DB?

I tried the https://packagist.org/packages/localgod/pdo-service-provider

but don't know which driver I have to use.

  • 写回答

1条回答 默认 最新

  • douke3007 2015-05-04 17:03
    关注

    You shouldn't over think it, at the end you're just using PDO so check the PDO's manual and use the SQLSRVR driver.

    NOTE: I've never used PDO in Ms SQL, but once installed the driver it should be straight forward to use, from the comments on the SQLSRV:

    As of 12/12/2014, Microsoft has officially released Version 3.1.

    Support for 5.5 has 4 drivers php_pdo_sqlsrv_55_nts.dll php_pdo_sqlsrv_55_ts.dll php_sqlsrv_55_nts.dll php_sqlsrv_55_ts.dll

    Note: Version 3.1 now supports PHP 5.5 and requires Microsoft ODBC Driver 11 (or higher)

    You can downlod the new driver from http://www.microsoft.com/en-us/download/details.aspx?id=20098

    So, once enabled you can just use the sqlsrv and this should work (or you can skip this provider and use raw PDO: $c = new PDO("sqlsrv:Server=localhost;Database=testdb", "UserName", "Password");)

    Edited to give Linux/Unix instructions:

    If you are running your PHP code from linux, you just need to use de default ODBC driver (from the docs: The PDO_SQLSRV extension is only compatible with PHP running on Windows. For Linux, see ODBC and » Microsoft's SQL Server ODBC Driver for Linux.)

    Also take a look at this answer.

    评论

报告相同问题?

悬赏问题

  • ¥15 对于这个复杂问题的解释说明
  • ¥50 三种调度算法报错 采用的你的方案
  • ¥15 关于#python#的问题,请各位专家解答!
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败