简体   繁体   English

使SQL Server的ODBC Driver 11适用于Azure网站中的PHP

[英]Making ODBC Driver 11 for SQL Server Available For PHP In Azure Website

I have a PHP 5.5 website running WordPress in Azure Websites configured to run with 64-bit IIS, with the database running in MySQL. 我有一个在Azure网站中运行WordPress的PHP 5.5网站,该网站配置为与64位IIS一起运行,并且数据库在MySQL中运行。 I want to convert the site to use SQL Server in Azure instead of MySQL. 我想将站点转换为在Azure中使用SQL Server而不是MySQL。

I've installed the WP Db Abstraction plugin, and followed its setup instructions. 我已经安装了WP Db Abstraction插件,并按照其设置说明进行操作。 I've elected to use the sqlsrv driver, so I've installed the Microsoft Drivers for PHP for SQL Server 3.1 and added them into a folder in the WordPress website and configured them as an extension. 我选择使用sqlsrv驱动程序,因此我已经安装了Microsoft SQL Server 3.1的PHP驱动程序 ,并将它们添加到WordPress网站的文件夹中,并将其配置为扩展名。 Calling phpinfo() on a test page shows that the sqlsrv driver has been loaded into PHP, and also reports that PHP is x86. 在测试页上调用phpinfo()表示sqlsrv驱动程序已加载到PHP中,并且还报告PHP为x86。

I've also setup the database, user and password and tested that I can connect to it successfully using SQLCMD. 我还设置了数据库,用户和密码,并测试了可以使用SQLCMD成功连接到它。

The Microsoft Drivers for PHP for SQL Server 3.1 instructions state that the "Microsoft ODBC Driver 11 for SQL Server version 11" is also required. Microsoft SQL Server 3.1的PHP驱动程序说明中指出“ SQL Server 11版的Microsoft ODBC驱动程序11”也是必需的。 I've downloaded the x64 and x86 versions and tried the DLLs out of the relevant Windows directories and added them to the extension directory alongside the PHP drivers for both architectures but neither has worked. 我已经下载了x64和x86版本,并尝试从相关的Windows目录中删除这些DLL,并将它们与两种结构的PHP驱动程序一起添加到扩展目录中,但均未起作用。

When trying to connect to the SQL Azure Database from the running PHP site, I just get this error: 当尝试从正在运行的PHP站点连接到SQL Azure数据库时,我仅收到此错误:

This extension requires the ODBC Driver 11 for SQL Server. Access the following URL to download the ODBC Driver 11 for SQL Server for x86: http://go.microsoft.com/fwlink/?LinkId=163712

The DLL files for the drivers I have relative to the WordPress site root are: 我相对于WordPress网站根目录的驱动程序的DLL文件是:

  • ext\\msodbcsql11.dll
  • ext\\php_sqlsrv_55_nts.dll
  • ext\\1033\\msodbcsqlr11.rll

I have the following set in the Azure Management Portal for the website for the App Settings: 我在Azure管理门户中为网站的应用程序设置进行了以下设置:

PHP_EXTENSIONS:ext\\php_sqlsrv_55_nts.dll

All I can figure is that I'm either missing something from the ODBC drivers, or how I'm going about making them available to the PHP driver is incorrect. 我所能想到的是,我或者缺少ODBC驱动程序中的某些东西,或者我打算如何将它们提供给PHP驱动程序是不正确的。

Does anyone have any ideas as to what I've missed, or why this isn't working? 是否有人对我错过的内容有任何想法,或者为什么这不起作用?

Below is the test code I'm using to test the SQL Server connectivity in PHP. 下面是我用来测试PHP中SQL Server连接性的测试代码。

<?php
$serverName = "MYSERVER.database.windows.net,1433";
$connOptions = array("UID"=>"MYUSERNAME", "PWD"=>"MYPASSWORD");
$conn = sqlsrv_connect( $serverName, $connOptions );

if( $conn === false ) {
    die( print_r( sqlsrv_errors(), true));
}

if( $client_info = sqlsrv_client_info( $conn)) {
    foreach( $client_info as $key => $value) {
        echo $key.": ".$value."<br />";
    }
} else {
    echo "Error in retrieving client info.<br />";
}
?>

I didn't really find a proper solution to this in the end, but it turned out that all the bits for using SQL Server with PHP 5.4 are already installed in Azure Websites. 最后,我并没有真正找到合适的解决方案,但事实证明,Azure网站已安装了将SQL Server与PHP 5.4结合使用的所有功能。

I downgraded from PHP 5.5 to 5.4 and then SQL Server connectivity started working. 我从PHP 5.5降级到5.4,然后SQL Server连接开始工作。

Not really a fix, but it's gotten me to the position (mostly) that I wanted. 并不是真正的解决方法,但是它已经使我(通常)到达了想要的位置。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 此扩展需要PHP中用于SQL Server的Microsoft ODBC Driver 11 - This extension requires the Microsoft ODBC Driver 11 for SQL Server in PHP 无法通过用于SQL Server和SQL Native Client的ODBC驱动程序11连接到Azure数据库 - Cannot Connect to Azure Database through ODBC Driver 11 for SQL Server and SQL Native Client PHP PDO Microsoft SQL Server:SQLSTATE [24000]:[Microsoft] [用于SQL Server的ODBC驱动程序11]-无效的游标状态 - PHP PDO Microsoft SQL Server: SQLSTATE[24000]: [Microsoft][ODBC Driver 11 For SQL Sever] - Invalid Cursor State 如何使用PHP在RedHat Linux上为SQLServer®配置Microsoft®ODBC驱动程序11 - How to Configure Microsoft® ODBC Driver 11 for SQL Server® on RedHat Linux with PHP 使用ODBC驱动程序13代替ODBC驱动程序11连接到SQL Server 2008 R2 - Using ODBC Driver 13 instead of ODBC Driver 11 to Connect to SQL Server 2008 R2 带PHP的RedHat Linux上用于SQLServer®的Microsoft®ODBC驱动程序11-与PDO的存储过程绑定参数时出现错误 - Microsoft® ODBC Driver 11 for SQL Server® on RedHat Linux with PHP - gives an error when bind parameter with PDO for stored procedures 为 Microsoft SQL 服务器安装 ODBC 驱动程序和 php 驱动程序 ZA5C95B86291EA2709FCBE64458ED 服务器 - Install ODBC driver and php drivers for Microsoft SQL Server for Laravel Sail 使用FreeTDS ODBC驱动程序将Linux PHP连接到SQL Server - Using a FreeTDS ODBC driver to connect Linux PHP to a SQL Server 此扩展需要 Microsoft ODBC Driver 11 for SQL Server 才能与 SQL Server 通信 - This extension requires the Microsoft ODBC Driver 11 for SQL Server to communicate with SQL Server SQLSTATE [HY000]:[Microsoft] [SQL Server的ODBC驱动程序11] TDS协议错误 - SQLSTATE[HY000]: [Microsoft][ODBC Driver 11 for SQL Server]TDS Protocol error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM