Merge pull request #473 from yitam/twoTests

Temporary entity names to ensure uniqueness
This commit is contained in:
Jenny Tam 2017-07-12 16:36:06 -07:00 committed by GitHub
commit 8dea7eb211
2 changed files with 5 additions and 11 deletions

View file

@ -165,7 +165,7 @@ function GetTempTableName($table = '', $temporary = true)
// dropped once the connection is closed. Otherwise, the caller
// should take care of dropping the temp table afterwards.
$timestamp = round(microtime(true)*1000);
$someNumber = rand(0, 1000);
$prefix = '';
if ($temporary)
@ -174,7 +174,7 @@ function GetTempTableName($table = '', $temporary = true)
if (strlen($table) == 0)
$table = 'php_test_table';
return $prefix . $table . '_' . $timestamp;
return $prefix . $table . '_' . $someNumber;
}
function GetTempProcName($proc = '', $temporary = true)
@ -183,7 +183,7 @@ function GetTempProcName($proc = '', $temporary = true)
// automatically dropped once the connection is closed. Otherwise,
// the caller should take care of dropping the temp procedure afterwards.
$timestamp = round(microtime(true)*1000);
$someNumber = rand(0, 1000);
$prefix = '';
if ($temporary)
@ -192,7 +192,7 @@ function GetTempProcName($proc = '', $temporary = true)
if (strlen($proc) == 0)
$proc = 'php_test_proc';
return $prefix . $proc . '_' . $timestamp;
return $prefix . $proc . '_' . $someNumber;
}
function ExecuteQuery($conn, $query)

View file

@ -12,13 +12,7 @@ if( !$conn ) {
}
// Set database name
$dbUniqueName = "php_uniqueDB01";
// DROP database if exists
$stmt = sqlsrv_query($conn,"IF EXISTS(SELECT name FROM sys.databases WHERE name = '"
.$dbUniqueName."') DROP DATABASE ".$dbUniqueName);
if($stmt === false){ die( print_r( sqlsrv_errors(), true )); }
sqlsrv_free_stmt($stmt);
$dbUniqueName = "php_uniqueDB_" . rand(0, 1000);
// CREATE database
$stmt = sqlsrv_query($conn,"CREATE DATABASE ". $dbUniqueName);