php-sqlsrv/test/functional/sqlsrv/srv_075_database.phpt

40 lines
876 B
Plaintext
Raw Normal View History

2017-01-10 22:59:16 +01:00
--TEST--
2017-02-01 01:38:45 +01:00
Drop missing database
2017-01-10 22:59:16 +01:00
--SKIPIF--
<?php require('skipif_azure.inc'); ?>
2017-01-10 22:59:16 +01:00
--FILE--
<?php
require_once("MsCommon.inc");
2017-01-10 22:59:16 +01:00
$conn = connect(array("Database"=>'master'));
if (!$conn) {
fatalError("Connection could not be established.\n");
2017-01-10 22:59:16 +01:00
}
// Set database name
$dbUniqueName = "uniqueDB01";
// DROP database if exists
$stmt = sqlsrv_query($conn, "IF EXISTS(SELECT name FROM sys.databases WHERE name = '"
.$dbUniqueName."') DROP DATABASE ".$dbUniqueName);
2017-01-10 22:59:16 +01:00
sqlsrv_free_stmt($stmt);
// DROP missing database
$stmt = sqlsrv_query($conn, "DROP DATABASE ". $dbUniqueName);
2017-01-10 22:59:16 +01:00
var_dump($stmt);
if ($stmt === false) {
$res = array_values(sqlsrv_errors());
var_dump($res[0]['code']);
} else {
printf("%-20s\n", "ERROR: DROP missing database MUST return bool(false)");
2017-01-10 22:59:16 +01:00
}
sqlsrv_close($conn);
print "Done";
?>
--EXPECTREGEX--
bool\(false\)
int\((3701|911)\)
2017-02-01 01:38:45 +01:00
Done