我试图通过
从php连接到Azure DB$connectionInfo = array("UID" => "xxx@xxx", "pwd" => "xxx", "Database" => "xxx");
$serverName = "tcp:xxx.database.windows.net,1433";
$conn = sqlsrv_connect($serverName, $connectionInfo);
但是它给了我
致命错误:调用未定义函数sqlsrv_connect()在C:'wamp'www...'index.php第19行
您必须首先使用SQL Server本地驱动程序为php,然后您可以做如下操作:
$serverName = "tcp:sample.database.windows.net, 1433";
$connectionOptions = array("Database" => "sampleInit",
"UID" => "sampleUsr@sample",
"PWD" => "samplePass",
"MultipleActiveResultSets" => false);
$conn = sqlsrv_connect($serverName, $connectionOptions);
if($conn === false)
{
die(print_r(sqlsrv_errors(), true));
}
你可以阅读更多关于PHP和SQL Azure的博客文章:
http://blogs.msdn.com/b/brian_swan/archive/2010/02/12/getting-started-with-php-and-sql-azure.aspx
我将此dll添加到ext/文件夹中,然后将extension=php_sqlsrv.dll
添加到php7/文件夹中的php.ini中。