本文整理汇总了PHP中DbUtil::switchRestore方法的典型用法代码示例。如果您正苦于以下问题:PHP DbUtil::switchRestore方法的具体用法?PHP DbUtil::switchRestore怎么用?PHP DbUtil::switchRestore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DbUtil
的用法示例。
在下文中一共展示了DbUtil::switchRestore方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_records_to_print
function get_records_to_print($lab_config, $test_type_id, $date_from, $date_to)
{
$saved_db = DbUtil::switchToLabConfig($lab_config->id);
$retval = array();
$query_string = "SELECT * FROM test WHERE test_type_id={$test_type_id} " . "AND specimen_id IN ( " . "SELECT specimen_id FROM specimen " . "WHERE date_collected BETWEEN '{$date_from}' AND '{$date_to}' " . ")";
$resultset = query_associative_all($query_string, $row_count);
foreach ($resultset as $record) {
$test = Test::getObject($record);
$specimen = Specimen::getById($test->specimenId);
$patient = Patient::getById($specimen->patientId);
$retval[] = array($test, $specimen, $patient);
}
DbUtil::switchRestore($saved_db);
return $retval;
}
示例2: generate_worksheet_config
function generate_worksheet_config($lab_config_id)
{
$lab_config = LabConfig::getById($lab_config_id);
$test_ids = $lab_config->getTestTypeIds();
$saved_db = DbUtil::switchToLabConfig($lab_config_id);
foreach ($test_ids as $test_id) {
$test_entry = TestType::getById($test_id);
$query_string = "SELECT * FROM report_config WHERE test_type_id={$test_id} LIMIT 1";
$record = query_associative_one($query_string);
if ($record == null) {
# Add new entry
$query_string_add = "INSERT INTO report_config (" . "test_type_id, header, footer, margins, " . "p_fields, s_fields, t_fields, p_custom_fields, s_custom_fields " . ") VALUES (" . "'{$test_id}', 'Worksheet - " . $test_entry->name . "', '', '5,0,5,0', " . "'0,1,0,1,1,0,0', '0,0,1,1,0,0', '1,0,1,0,0,0,0,1', '', '' " . ")";
query_insert_one($query_string_add);
}
}
DbUtil::switchRestore($saved_db);
}
示例3: updateDatabase
function updateDatabase()
{
global $labConfigId, $DB_HOST, $DB_USER, $DB_PASS;
$country = strtolower(LabConfig::getUserCountry($labConfigId));
$saved_db = DbUtil::switchToCountry($country);
$currentDir = getcwd();
$mainBlisDir = substr($currentDir, $length, strpos($currentDir, "htdocs"));
//$blisLabBackupFilePath = "\"".$mainBlisDir.$backup_folder."\blis_".$lab_config_id."\blis_".$lab_config_id."_backup.sql\"";
$sqlFilePath = "\"" . $mainBlisDir . "htdocs\\export\\temp.sql\"";
$mysqlExePath = "\"" . $mainBlisDir . "server\\mysql\\bin\\mysql.exe\"";
$dbname = "blis_" . $country;
$command = $mysqlExePath . " -h {$DB_HOST} -P 7188 -u {$DB_USER} -p{$DB_PASS} {$dbname} < {$sqlFilePath}";
$command = "C: &" . $command;
//the C: is a useless command to prevent the original command from failing because of having more than 2 double quotes
echo $command;
system($command, $return_var);
if ($return_var == 0) {
echo "true";
} else {
echo "false";
}
DbUtil::switchRestore($saved_db);
}
示例4:
<?php
#
# Deletes a test type from DB
# Sets disabled flag to true instead of deleting the record
# This maintains info for samples that were linked to this test type previously
#
include "../includes/db_lib.php";
$saved_session = SessionUtil::save();
$saved_db = DbUtil::switchToGlobal();
$test_type_id = $_REQUEST['id'];
TestType::deleteById($test_type_id);
DbUtil::switchRestore($saved_db);
SessionUtil::restore($saved_session);
header("Location: catalog.php?tdel");
示例5: getRangeInfectionStats
$i++;
}
DbUtil::switchRestore($saved_db);
return $retval;
}
public static function getRangeInfectionStats($lab_config, $date_from, $date_to)
{
$test_type_list = get_range_value_test_types($lab_config);
# For each test type, fetch all measures
# For each measure, create distribution based on range
foreach ($test_type_list as $test_type_id) {
# Collect measure(s) information
$measure_list = get_test_type_measures($test_type_id);
$measure_meta_list = array();
foreach ($measure_list as $measure_id) {
$measure = get_measure_by_id($measure_id);
$measure_meta = new MeasureMeta();
$measure_meta->name = $measure->getName();
$measure_meta->countParts = array();
$range = $measure->range;
if (strpos($range, ":") === false) {
# Discrete value range
$range_options = explode("#", $range);
$measure_meta->rangeType = MeasureMeta::$DISCRETE;
$measure_meta->rangeValues = $range_options;
} else {
# Continuous value range
$range_bounds = explode(":", $range);
$measure_meta->rangeType = MeasureMeta::$CONTINUOUS;
$measure_meta->rangeValues = $range_bounds;
}
$measure_meta_list[] = $measure_meta;
}
# Calculate stats
$query_string = "SELECT COUNT(*) AS count_val FROM test t, specimen s " . "WHERE t.test_type_id={$test_type_id} " . "AND t.specimen_id=s.specimen_id " . "AND ( s.date_collected BETWEEN '{$date_from}' AND '{$date_to}' ) " . "AND t.result <> ''";
$record = query_associative_one($query_string);
$count_all = $record['count_val'];
# Fetch result values
$query_string = "SELECT t.result FROM test t, specimen s " . "WHERE t.test_type_id={$test_type_id} " . "AND t.specimen_id=s.specimen_id " . "AND ( s.date_collected BETWEEN '{$date_from}' AND '{$date_to}' ) " . "AND t.result <> ''";
$resultset = query_associative_all($query_string, $row_count);
foreach ($resultset as $record) {
$result_string = substr($record['result'], 0, -1);
$result_list = explode(",", $result_string);
for ($i = 0; $i < count($result_list); $i++) {
$measure_meta = $measure_meta_list[$i];
if ($measure_meta->rangeType == MeasureMeta::$CONTINUOUS) {
$range_bounds = $measure_meta->rangeValues;
$interval = $range_bounds[1] - $range_bounds[0];
$base = $interval / 10;
$offset = $result_list[$i] - $range_bounds[0];
$bucket = $offset / $base;
echo $bucket;
break;
示例6: checkNameExists
public static function checkNameExists($name, $country)
{
# Checks if the given patient name (or similar match) already exists
$saved_db = DbUtil::switchToCountry($country);
$query_string = "SELECT COUNT(patient_id) AS val FROM patient WHERE name LIKE '%{$name}%'";
$resultset = query_associative_one($query_string);
DbUtil::switchRestore($saved_db);
if ($resultset == null || $resultset['val'] == 0) {
return false;
} else {
return true;
}
}
示例7: getEditCustomWorksheetForm
//.........这里部分代码省略.........
<br>
<?php
if($worksheet->userFields == null || count($worksheet->userFields) == 0)
{
//echo LangUtil::$generalTerms['NO']."<br>";
}
foreach($worksheet->userFields as $field_entry)
{
$field_id = $field_entry[0];
$field_name = $field_entry[1];
$field_width = $field_entry[2];
?>
<input type='hidden' name='existing_uf_id[]' value='<?php echo $field_id; ?>'></input>
<input type='text' name='existing_uf_name[]' value='<?php echo $field_name; ?>' class='uniform_width'></input>
<input type='text' name='existing_uf_width[]' size='2' value='<?php echo $field_width; ?>'></input>
<br>
<?php
}
?>
</span>
<small><a href='javascript:add_another_uf();'><?php echo LangUtil::$generalTerms['ADDNEW']; ?>»</a></small>
</td>
</tr>
<tr valign='top'>
<td><?php echo LangUtil::$generalTerms['LAB_SECTION']; ?></td>
<td>
<?php
$test_type_id = $worksheet->testTypes[0];
$saved_db = DbUtil::switchToGlobal();
$query_string = "SELECT test_category_id FROM test_type WHERE test_type_id=$test_type_id";
$record = query_associative_one($query_string);
$cat_code = $record['test_category_id'];
$cat_name = get_test_category_name_by_id($cat_code);
DbUtil::switchRestore($saved_db);
echo $cat_name;
?>
</td>
</tr>
</table>
<br>
<div id='test_boxes' class='smaller_font' style='width:auto;'>
<?php
$test_type_list = get_test_types_by_site_category($lab_config->id, $cat_code);
foreach($test_type_list as $test_type)
{
$measure_list = $test_type->getMeasures();
?>
<div>
<input type='checkbox' class='test_type_checkbox' name='ttype_<?php echo $test_type->testTypeId; ?>' id='ttype_<?php echo $test_type->testTypeId; ?>' <?php
if(in_array($test_type->testTypeId, $worksheet->testTypes))
echo " checked ";
?>>
<?php echo $test_type->getName(); ?>
</input>
<br>
<div id='ttype_<?php echo $test_type->testTypeId; ?>_mlist' style='position:relative; margin-left:15px;<?php
if(in_array($test_type->testTypeId, $worksheet->testTypes) === false)
echo "display:none;";
?>'>
<table class='hor-minimalist-b'>
<thead>
<tr>
<th style='width:200px;'><?php echo LangUtil::$generalTerms['MEASURES']; ?></th>
<th><?php echo LangUtil::$pageTerms['COLUMN_WIDTH']; ?> (%)</th>
</tr>
<?php
示例8: runGlobalUpdate
function runGlobalUpdate()
{
global $con;
$saved_db = DbUtil::switchToGlobal();
/* BLIS 1.35 Update
$query_insert = "CREATE TABLE test_mapping (".
"user_id int(11), ".
"test_name varchar(256), ".
"lab_id_test_id varchar(256), ".
"test_id int(10) unsigned, ".
"test_category_id int(10) unsigned, ".
"primary key (user_id, test_id) )";
mysql_query( $query_insert, $con ) or die(mysql_error());
$query_insert = "CREATE TABLE specimen_mapping (".
"user_id int(11), ".
"specimen_name varchar(256), ".
"lab_id_specimen_id varchar(256), ".
"specimen_id int(10), ".
"primary key (user_id, specimen_id) )";
mysql_query( $query_insert, $con ) or die(mysql_error());
$query_insert = "CREATE TABLE test_category_mapping (".
"user_id int(11), ".
"test_category_name varchar(256), ".
"lab_id_test_category_id varchar(256), ".
"test_category_id int(10), ".
"primary key (user_id, test_category_id) )";
mysql_query( $query_insert, $con ) or die(mysql_error());
$query_insert = "CREATE TABLE measure_mapping (".
"user_id int(11), ".
"measure_name varchar(256), ".
"lab_id_measure_id varchar(256), ".
"measure_id int(10), ".
"primary key (user_id, measure_id) )";
mysql_query( $query_insert, $con ) or die(mysql_error());
$query_insert = "CREATE TABLE global_measures (".
"user_id int(11), ".
"name varchar(128), ".
"range varchar(1024), ".
"test_id int(10), ".
"measure_id int(10), ".
"unit varchar(64), ".
"primary key (user_id, test_id, measure_id) )";
mysql_query( $query_insert, $con ) or die(mysql_error());
$query_insert = "CREATE TABLE infection_report_settings (".
"id int(10) unsigned, ".
"group_by_age int(10) unsigned, ".
"group_by_gender int(10) unsigned, ".
"age_groups varchar(512), ".
"measure_groups varchar(512), ".
"measure_id int(10), ".
"user_id int(11), ".
"test_id int(10), ".
"primary key (user_id, id) )";
mysql_query( $query_insert, $con ) or die(mysql_error());
$query_insert = "CREATE TABLE reference_range_global (".
"measure_id int(10), ".
"age_min varchar(64), ".
"age_max varchar(64), ".
"sex varchar(64), ".
"range_lower varchar(64), ".
"range_upper varchar(64), ".
"user_id int(11), ".
"primary key (user_id, measure_id) )";
mysql_query( $query_insert, $con ) or die(mysql_error());
$query_insert = "INSERT INTO user (user_id, username, `password`, actualname, email, lang_id, `level`, created_by, lab_config_id, phone) ".
"VALUES (401, 'philip', '18865bfdeed2fd380316ecde609d94d7285af83f', 'Philip Boakye', 'boakyephilip@ymail.com', 'en', 4, 0, 0, '')";
mysql_query( $query_insert, $con ) or die(mysql_error());
$query_insert = "INSERT INTO user (user_id, username, `password`, actualname, email, lang_id, `level`, created_by, lab_config_id, phone) ".
"VALUES (402, 'mercy', '18865bfdeed2fd380316ecde609d94d7285af83f', 'Mercy Maeda', 'mirygibson@yahoo.com', 'en', 4, 0, 0, '')";
mysql_query( $query_insert, $con ) or die(mysql_error());
*/
/* BLIS 1.91 Update */
$query_alter = "ALTER table lab_config" . "ADD column country varchar(512)";
mysql_query($query_alter, $con) or die(mysql_error());
DbUtil::switchRestore($saved_db);
}
示例9: processWeeklyTrends
function processWeeklyTrends($lab_config_id, $test_type_id, $date_from, $date_to, $test_name = null)
{
global $namesArray;
global $stat_list;
# All Tests & All Labs */
if ($test_type_id == 0 && $lab_config_id == 0) {
$site_list = get_site_list($_SESSION['user_id']);
$userId = $_SESSION['user_id'];
$saved_db = DbUtil::switchToGlobal();
$query = "SELECT * FROM test_mapping WHERE user_id = {$userId}";
$resultset = query_associative_all($query, $row_count);
foreach ($resultset as $record) {
$labIdTestIds = explode(';', $record['lab_id_test_id']);
foreach ($labIdTestIds as $labIdTestId) {
$labIdTestId = explode(':', $labIdTestId);
$labId = $labIdTestId[0];
$testId = $labIdTestId[1];
$test_type_list_all[$labId][] = $testId;
$test_type_names[$labId][] = $record['test_name'];
}
}
DbUtil::switchRestore($saved_db);
foreach ($site_list as $key => $value) {
$lab_config = LabConfig::getById($key);
$test_type_list = array();
$test_type_list = $test_type_list_all[$key];
$testNames = $test_type_names[$key];
$saved_db = DbUtil::switchToLabConfig($lab_config->id);
$testCount = -1;
foreach ($test_type_list as $test_type_id) {
$query_string = "SELECT COUNT(*) AS count_val FROM test t, specimen s " . "WHERE t.test_type_id={$test_type_id} " . "AND t.specimen_id=s.specimen_id " . "AND result!=''" . "AND ( s.date_collected BETWEEN '{$date_from}' AND '{$date_to}' )";
$record = query_associative_one($query_string);
$count_all = intval($record['count_val']);
$testCount++;
if ($count_all == 0) {
continue;
}
$namesArray[] = $lab_config->name . " - " . $testNames[$testCount];
getWeeklyStats($lab_config, $test_type_id, $date_from, $date_to);
}
}
} else {
if ($test_type_id == 0 && count($lab_config_id) == 1) {
$lab_config = LabConfig::getById($lab_config_id[0]);
$test_type_list = get_discrete_value_test_types($lab_config);
foreach ($test_type_list as $test_type_id) {
$namesArray[] = get_test_name_by_id($test_type_id, $lab_config_id[0]);
getWeeklyStats($lab_config, $test_type_id, $date_from, $date_to);
}
} else {
if ($test_type_id == 0 && count($lab_config_id) > 1) {
$userId = $_SESSION['user_id'];
$saved_db = DbUtil::switchToGlobal();
$query = "SELECT * FROM test_mapping WHERE user_id = {$userId}";
$resultset = query_associative_all($query, $row_count);
foreach ($resultset as $record) {
$labIdTestIds = explode(';', $record['lab_id_test_id']);
foreach ($labIdTestIds as $labIdTestId) {
$labIdTestId = explode(':', $labIdTestId);
$labId = $labIdTestId[0];
$testId = $labIdTestId[1];
$test_type_list_all[$labId][] = $testId;
$test_type_names[$labId][] = $record['test_name'];
}
}
DbUtil::switchRestore($saved_db);
foreach ($lab_config_id as $key) {
$lab_config = LabConfig::getById($key);
$test_type_list = array();
$test_type_list = $test_type_list_all[$key];
$testNames = $test_type_names[$key];
$saved_db = DbUtil::switchToLabConfig($lab_config->id);
$testCount = -1;
foreach ($test_type_list as $test_type_id) {
$query_string = "SELECT COUNT(*) AS count_val FROM test t, specimen s " . "WHERE t.test_type_id={$test_type_id} " . "AND t.specimen_id=s.specimen_id " . "AND result!=''" . "AND ( s.date_collected BETWEEN '{$date_from}' AND '{$date_to}' )";
$record = query_associative_one($query_string);
$count_all = intval($record['count_val']);
$testCount++;
if ($count_all == 0) {
continue;
}
$namesArray[] = $lab_config->name . " - " . $testNames[$testCount];
getWeeklyStats($lab_config, $test_type_id, $date_from, $date_to);
}
}
} else {
/* Build Array Map with Lab Id as Key and Test Id as corresponding Value */
$labIdTestIds = explode(";", $test_type_id);
$testIds = array();
foreach ($labIdTestIds as $labIdTestId) {
$labIdTestIdsSeparated = explode(":", $labIdTestId);
$labId = $labIdTestIdsSeparated[0];
$testId = $labIdTestIdsSeparated[1];
$testIds[$labId] = $testId;
}
# Particular Test & All Labs
if ($test_type_id != 0 && $lab_config_id == 0) {
$site_list = get_site_list($_SESSION['user_id']);
foreach ($site_list as $key => $value) {
$lab_config = LabConfig::getById($key);
//.........这里部分代码省略.........
示例10: remarks_db2xml
function remarks_db2xml($langdata_path, $lab_config_id)
{
# Creates XML file from existing test measures (indicators) in catalog
global $VERSION;
$new_version = $VERSION;
$handle = fopen($langdata_path . "remarks.xml", "w");
$string_data = <<<EOF
<?xml version="1.0"?>
<measures version="{$new_version}">
EOF;
fwrite($handle, $string_data);
$saved_db = DbUtil::switchToLabConfigRevamp($lab_config_id);
$query_string = "SELECT * FROM measure";
$resultset = query_associative_all($query_string, $row_count);
foreach ($resultset as $record) {
$curr_measure = Measure::getObject($record);
$id = $curr_measure->measureId;
$descr = $curr_measure->name;
$string_data = <<<EOF
\t<measure id="{$id}" descr="{$descr}">
EOF;
fwrite($handle, $string_data);
$range_type = $curr_measure->getRangeType();
$range_values = $curr_measure->getRangeValues();
if ($range_type == Measure::$RANGE_NUMERIC) {
$lower_bound = htmlspecialchars($range_values[0]);
$upper_bound = htmlspecialchars($range_values[1]);
$string_data = <<<EOF
\t\t<range>
\t\t\t<key>{$range_values['0']}:{$range_values['1']}</key>
\t\t\t<value></value>
\t\t</range>
EOF;
fwrite($handle, $string_data);
} else {
if ($range_type == Measure::$RANGE_OPTIONS) {
foreach ($range_values as $range_value) {
$range_value_xml = htmlspecialchars($range_value);
$string_data = <<<EOF
\t\t<range>
\t\t\t<key>{$range_value_xml}</key>
\t\t\t<value></value>
\t\t</range>
EOF;
fwrite($handle, $string_data);
}
}
}
$string_data = <<<EOF
\t</measure>
EOF;
fwrite($handle, $string_data);
}
$string_data = <<<EOF
</measures>
EOF;
fwrite($handle, $string_data);
fclose($handle);
DbUtil::switchRestore($saved_db);
}
示例11: get_test_cost
public function get_test_cost($tid)
{
if ($_SESSION['level'] < 2 || $_SESSION['level'] > 4) {
$user = get_user_by_id($_SESSION['user_id']);
$lid = $user->labConfigId;
}
if ($lid == null) {
$lid = get_lab_config_id_admin($_SESSION['user_id']);
}
//$stocks_list = Inventory::getStocksList($lid, $r_id);
$lab_config_id = $lid;
$saved_db = DbUtil::switchToLabConfig($lab_config_id);
$query_string = "SELECT * from test_type_costs WHERE test_type_id = {$tid} ORDER BY earliest_date_valid DESC LIMIT 1";
$record = query_associative_one($query_string);
DbUtil::switchRestore($saved_db);
if ($record != null) {
$ret = $record['amount'];
} else {
$ret = -1;
}
return $ret;
}
示例12: get_inv_usage_by_user
public function get_inv_usage_by_user($lid, $user)
{
$lab_config_id = $lid;
$saved_db = DbUtil::switchToLabConfig($lab_config_id);
$query_string = "SELECT * from inv_usage WHERE user_id = {$user}";
$recordset = query_associative_all($query_string, $row_count);
DbUtil::switchRestore($saved_db);
return $recordset;
}
示例13: clear_random_data
function clear_random_data($lab_config)
{
# TODO:
if ($lab_config == null) {
return;
}
# Remove entries from 'test' table and 'specimen' table
global $MAX_NUM_PATIENTS, $MAX_NUM_SPECIMENS, $PATIENT_ID_START, $SPECIMEN_ID_START;
$saved_db = DbUtil::switchToLabConfig($lab_config->id);
for ($i = $SPECIMEN_ID_START; $i <= $SPECIMEN_ID_START + $MAX_NUM_SPECIMENS; $i++) {
$query_string = "DELETE FROM test WHERE specimen_id={$i}";
query_blind($query_string);
$query_string = "DELETE FROM specimen WHERE specimen_id={$i}";
query_blind($query_string);
}
# Remove entries from 'patient' table
for ($i = $PATIENT_ID_START; $i <= $PATIENT_ID_START + $MAX_NUM_PATIENTS; $i++) {
$query_string = "DELETE FROM patient WHERE patient_id={$i}";
query_blind($query_string);
}
DbUtil::switchRestore($saved_db);
}