dtwxmn8741 2017-11-05 20:27
浏览 56

SQL Server:数据库仅在PHP中处于“恢复”状态

When I restore a database with the SQL Server Management Studio it works just fine.
But when I restore it from the php ( using the function sqlsrv_query ), the database gets stuck on "Restoring..." state.

The sql query I use is this one:

RESTORE DATABASE WEB FROM DISK = 'C:\Program Files (x86)\Zend\Apache24\htdocs\db\WEB.bak' WITH REPLACE,RECOVERY

I also tried to login with the SQL Server Authentication mode using the same user I use with the php ( on sqlsrv_connect ) and to execute the same query, it worked. Only PHP does the problem.

PHP Code:

<?php
$connection_info = array( "Database" => "master", "UID" => "sa", "PWD" => "workingpw" );
$sql_handle = sqlsrv_connect( "DESKTOP\SQLEXPRESS", $connection_info );
if( !$sql_handle ) die();
sqlsrv_configure( "WarningsReturnAsErrors", 0 );

sqlsrv_query($sql_handle, "RESTORE DATABASE WEB FROM DISK = '" . getcwd() . "\\db\\WEB.bak' WITH REPLACE,RECOVERY");
$stmt = sqlsrv_query($sql_handle, "USE WEB");

if($stmt === false)
{
    die(print_r(sqlsrv_errors())); 
}
else echo "Success!";
?>


After PHP execution the error
"[Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Database 'WEB' cannot be opened. It is in the middle of a restore." occurs. Restoring state

Please help.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 oracle集群安装出bug
    • ¥15 关于#python#的问题:自动化测试
    • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
    • ¥15 教务系统账号被盗号如何追溯设备
    • ¥20 delta降尺度方法,未来数据怎么降尺度
    • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
    • ¥15 再不同版本的系统上,TCP传输速度不一致
    • ¥15 高德地图2.0 版本点聚合中Marker的位置无法实时更新,如何解决呢?
    • ¥15 DIFY API Endpoint 问题。
    • ¥20 sub地址DHCP问题