我正在尝试通过
从php连接到Azure DB$connectionInfo = array("UID" => "xxx@xxx", "pwd" => "xxx", "Database" => "xxx");
$serverName = "tcp:xxx.database.windows.net,1433";
$conn = sqlsrv_connect($serverName, $connectionInfo);
但它给了我
致命错误:在第19行的C:\ wamp \ www ... \ index.php中调用未定义的函数sqlsrv_connect()
答案 0 :(得分:8)
你必须首先使用SQL Server native driver for 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
答案 1 :(得分:0)
我将this dll添加到ext /文件夹,然后将extension=php_sqlsrv.dll
添加到php7 /文件夹中的php.ini。