I tried to backup my database following the instruction from SQL Server: Database stuck in "Restoring" state. but i have my database stuck in "Restoring" state. php code below:
$database = "container";
$uid = "sa";
$pwd = "12345" ;
try {
$conn = new PDO( "sqlsrv:Server=localhostSQLEXPRESS;Database=$database",
$uid,
$pwd
//,array(PDO::ATTR_PERSISTENT => true)
);
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); }
catch( PDOException $e ) {
die( "Error connecting to SQL Server" ); }
echo "Connected to SQL Server
";
$backfile = 'C:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLBackupsql server bk' ;
echo "Connected to SQL Server
";
$backfile = 'C:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLBackupsql server bk' ;
$query = "RESTORE DATABASE child_database FROM DISK = '$backfile' WITH REPLACE, RECOVERY ";
$conn->exec($query);
After running this code I got my child_database stuck in restoring state.however I copy the sql command
RESTORE DATABASE child_database FROM DISK = 'C:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLBackupsql server bk' WITH REPLACE, RECOVERY
and run in microsoft sql server management tool it works just fine.
I try to run add php code
$conn->exec("RESTORE DATABASE child_database WITH RECOVERY");
I got an exception.
please help.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…