Xampp 中的 PHP PDO MSSQL?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21138469/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 03:50:58  来源:igfitidea点击:

PHP PDO MSSQL in Xampp?

phppdo

提问by Raz3rt

Ok, here is my situation:

好的,这是我的情况:

I have installed Xampp (v1.8.2) on my server to publish a webprogram i am making (php, html) for some people in my network. For the first time i have to connect to MSSQL 2008 server instead of MYSQL (phpmyadmin). over the past years i've always worked with the MySQL api and a little with MySQLi. I have read over the internet i must use PDO so i can succesfully connect to the MS database.

我已经在我的服务器上安装了 Xampp (v1.8.2) 来发布我正在为我网络中的一些人制作的网络程序 (php, html)。我第一次必须连接到 MSSQL 2008 服务器而不是 MYSQL (phpmyadmin)。在过去的几年里,我一直使用 MySQL api 和一些 MySQLi。我已经通过互联网阅读我必须使用 PDO 以便我可以成功连接到 MS 数据库。

As i can see PDO is not installed/activated. When i look into the PHP.ini file the only thing i see is:

正如我所看到的,未安装/激活 PDO。当我查看 PHP.ini 文件时,我唯一看到的是:

extension=php_mssql.dll

but no

但不是

extension=php_pdo_mssql.dll

i've read allot (i.e that i have to install soms dll files, that i have to install apache, PHP, PDO manually)

我已经阅读了分配(即我必须安装 soms dll 文件,我必须手动安装 apache、PHP、PDO)

What is the good way to make a successful connection to my mssql database?

成功连接到我的 mssql 数据库的好方法是什么?

Thanks

谢谢

回答by Kei

Though using PDO is a nice idea and will save you time, you can use Mssql extension. If you really want to use PDO_MSSQL, you should allow it in PHP.ini (the second string you posted is the right way to do that), but you should also have php_pdo_mssql.dll in your PHP's extension directory. You can find that file here

尽管使用 PDO 是一个不错的主意并且可以节省您的时间,但您可以使用Mssql 扩展名。如果你真的想使用 PDO_MSSQL,你应该在 PHP.ini 中允许它(你发布的第二个字符串是正确的方法),但你的 PHP 扩展目录中也应该有 php_pdo_mssql.dll。你可以在这里找到那个文件

回答by janhenkes

There are two MSSQL extensions: SQLSRV http://php.net/manual/en/book.sqlsrv.php(if your server/computer is a Windows box) and MSSQL http://php.net/manual/en/book.mssql.php(if your server/computer is a Linux or OSX box)

有两个 MSSQL 扩展:SQLSRV http://php.net/manual/en/book.sqlsrv.php(如果您的服务器/计算机是 Windows 机器)和 MSSQL http://php.net/manual/en/book .mssql.php(如果您的服务器/计算机是 Linux 或 OSX 机器)

If you are using Windows: use the SQLSRV PHP extension http://www.microsoft.com/en-us/download/details.aspx?id=20098.

如果您使用的是 Windows:使用 SQLSRV PHP 扩展http://www.microsoft.com/en-us/download/details.aspx?id=20098

If you use Linux/Debian follow the instructions in this article. If you use OSX, try something like this article http://blog.andyhunt.info/2013/11/29/php-mssql-pdo_dblib-freetds-support-on-mac-osx-10-9-mavericks/.

如果您使用 Linux/Debian,请按照本文中的说明进行操作。如果您使用 OSX,请尝试类似这篇文章http://blog.andyhunt.info/2013/11/29/php-mssql-pdo_dblib-freetds-support-on-mac-osx-10-9-mavericks/ 的内容

I am writing a basic MSSQL Database Object which is compatible with both the extensions: https://github.com/janjuna/mssql-db

我正在编写一个与两个扩展都兼容的基本 MSSQL 数据库对象:https: //github.com/janjuna/mssql-db