public static function switchRestore($db_name) { # Reverts back to saved DB instance global $DEBUG; if ($DEBUG) { echo "In switchRestore({$db_name})<br>"; echo DebugLib::getCallerFunctionName(debug_backtrace()) . "<br>"; } db_change($db_name); }
} fwrite($fileWriteHandle, $line); } fclose($fileWriteHandle); fclose($fileHandle); $blisLabBackupTempFilePath = "\"" . $mainBlisDir . "\\htdocsxport\\blis_" . $lab_config_id . "_temp_backup.sql\""; $mysqlExePath = "\"" . $mainBlisDir . "server\\mysql\\bin\\mysql.exe\""; $dbTempName = "blis_" . $lab_config_id . "_temp"; $command = $mysqlExePath . " -h {$DB_HOST} -P 7188 -u {$DB_USER} -p{$DB_PASS} {$dbTempName} < {$blisLabBackupTempFilePath}"; $command = "C: &" . $command; //the C: is a useless command to prevent the original command from failing because of having more than 2 double quotes system($command, $return); unlink($backupLabDbTempFileName); $saved_db = db_get_current(); $switchDatabaseName = "blis_" . $lab_config_id . "_temp"; db_change($switchDatabaseName); $queryUpdate = "UPDATE patient " . "SET name = hash_value"; query_blind($queryUpdate); $backupLabDbTempFileName = "blis_" . $lab_config_id . "_temp_backup.sql"; $count = 0; $command = $mysqldumpPath . " -B -h {$DB_HOST} -P 7188 -u {$DB_USER} -p{$DB_PASS} {$dbTempName} > {$backupLabDbTempFileName}"; system($command); DbUtil::switchRestore($saved_db); $query = "DROP DATABASE " . $dbname . "_temp"; mysql_query($query, $con); $fileHandle = fopen($backupLabDbTempFileName, "r"); $backupLabDbFileName = "blis_" . $lab_config_id . "_backup.sql"; unlink($backupLabDbFileName); $fileWriteHandle = fopen($backupLabDbFileName, "w"); while (!feof($fileHandle)) { $line = fgets($fileHandle);
$user->langId = "default"; add_user($user); } /* # Create revamp DB instance for this lab db_create($revamp_db_name); # Populate create_lab_config_revamp_tables($lab_config_id, $revamp_db_name); # Copy selected test types and specimen types to this database $lab_config->id = $lab_config_id; add_lab_config_with_id($lab_config); */ # Create DB instance for this lab db_create($db_name); # Switch to this new instance and create data tables db_change($db_name); create_lab_config_tables($lab_config_id, $db_name); # Generate initial worksheet configs if missing $lab_config = LabConfig::getById($lab_config_id); $lab_config->worksheetConfigGenerate(); # TODO: $saved_id = $_SESSION['lab_config_id']; $_SESSION['lab_config_id'] = $lab_config_id; //db_change($GLOBAL_DB_NAME); ## Add new entry for infection (disease) report # TODO: /* $site_settings = new DiseaseReport(); $site_settings->labConfigId = $lab_config_id; $site_settings->testTypeId = 0; $site_settings->measureId = 0;