IIS
PHP 5.2.3
MSSQL Server 2005 Express
I am having a problem using PDO to send a BACKUP statement to MSSQL.
This statement runs perfectly well in MSSQL 2005 Management Studio Express in the query window.
It just wont run from PHP. Maybe I am doing something wrong?
Can anyone help please?
returns a zero from the var_dump($rcount) below and it gives the success message but no file is produced.
Thanks,
Paul
Code: Select all
$dbuser = "xxxxx";
$dbpass = "xxxxx";
try {
$dbh = new PDO('mssql:host=\\\\.\pipe\\MSSQL$SQLEXPRESS\\sql\\query;dbname=project13', $dbuser, $dbpass);
} catch (PDOException $e) {
print "<BR>(1)Error!: " . $e->getMessage() . "<br/>";
exit;
}
$query = "BACKUP DATABASE [project13] TO DISK = N'project_backup.bak' WITH NOFORMAT,
NOINIT, NAME = N'This is a full project backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10;";
try
{
$rcount = $dbh->exec($query);
var_dump($rcount);
// var dump is zero, not false.
} catch (PDOException $e) {
error_log ("Backup failed: ".$query);
die(" Problem with Backup query statement $query");
}
echo "Database backed up!";
echo "<BR>========= end =============<BR>";
exit;