当前位置: 首页>>代码示例>>PHP>>正文


PHP DbUtil::switchToGlobal方法代码示例

本文整理汇总了PHP中DbUtil::switchToGlobal方法的典型用法代码示例。如果您正苦于以下问题:PHP DbUtil::switchToGlobal方法的具体用法?PHP DbUtil::switchToGlobal怎么用?PHP DbUtil::switchToGlobal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DbUtil的用法示例。


在下文中一共展示了DbUtil::switchToGlobal方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getDiscreteInfectionStatsAggregate

 public static function getDiscreteInfectionStatsAggregate($lab_config_id, $date_from, $date_to, $test_type_id)
 {
     $retval = array();
     #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;
             # For each test type, fetch negative records
             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 ( s.date_collected BETWEEN '{$date_from}' AND '{$date_to}' ) " . "AND (result LIKE 'N,%' OR result LIKE 'n�gatif,%' OR result LIKE 'negatif,%' OR result LIKE 'n,%' OR result LIKE 'negative,%')";
                 $record = query_associative_one($query_string);
                 $count_negative = intval($record['count_val']);
                 $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 total tests is 0, ignore
                 if ($count_all == 0) {
                     continue;
                 }
                 $testName = $testNames[$testCount];
                 if (!array_key_exists($testName, $retval)) {
                     $retval[$testName] = array($count_all, $count_negative);
                 } else {
                     $count_all += intval($retval[$testName][0]);
                     $count_negative += intval($retval[$testName][1]);
                     $retval[$testName] = array($count_all, $count_negative);
                 }
             }
         }
         DbUtil::switchRestore($saved_db);
         return $retval;
     } else {
         if ($test_type_id == 0 && count($lab_config_id) == 1) {
             $lab_config = LabConfig::getById($lab_config_id[0]);
             $retvalues = StatsLib::getDiscreteInfectionStats($lab_config, $date_from, $date_to);
             $saved_db = DbUtil::switchToLabConfig($lab_config->id);
             foreach ($retvalues as $key => $value) {
                 $testName = get_test_name_by_id($key);
                 $retval[$testName] = $value;
             }
             DbUtil::switchRestore($saved_db);
             return $retval;
         } 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;
                     # For each test type, fetch negative records
                     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 ( s.date_collected BETWEEN '{$date_from}' AND '{$date_to}' ) " . "AND (result LIKE 'N,%' OR result LIKE 'n�gatif,%' OR result LIKE 'negatif,%' OR result LIKE 'n,%' OR result LIKE 'negative,%')";
                         $record = query_associative_one($query_string);
                         $count_negative = intval($record['count_val']);
                         $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}' )";
                         //echo($query_string);
                         $record = query_associative_one($query_string);
                         $count_all = intval($record['count_val']);
                         $testCount++;
                         # If total tests is 0, ignore
                         if ($count_all == 0) {
//.........这里部分代码省略.........
开发者ID:caseyi,项目名称:BLIS,代码行数:101,代码来源:stats_lib.php

示例2:

<?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");
开发者ID:jfurlong,项目名称:BLIS,代码行数:15,代码来源:test_type_delete.php

示例3: getByKeys

 public static function getByKeys($user_id, $test_type_id, $measure_id)
 {
     # Fetches a record by compound key
     $saved_db = DbUtil::switchToGlobal();
     $query_string = "SELECT * FROM infection_report_settings " . "WHERE user_id={$user_id} " . "AND test_id={$test_type_id} " . "AND measure_id={$measure_id} LIMIT 1";
     $record = query_associative_one($query_string);
     $retval = GlobalInfectionReport::getObject($record);
     DbUtil::switchRestore($saved_db);
     return $retval;
 }
开发者ID:nchopra,项目名称:C4G-BLIS,代码行数:10,代码来源:db_lib.php

示例4: getEditCustomWorksheetForm


//.........这里部分代码省略.........
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					<?php echo LangUtil::$pageTerms['COLUMN_WIDTH']; ?>
					<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']; ?>&raquo;</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>
开发者ID:jfurlong,项目名称:BLIS,代码行数:67,代码来源:page_elemsdff.php

示例5: 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);
}
开发者ID:caseyi,项目名称:BLIS,代码行数:93,代码来源:updateDB.php

示例6: 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);
//.........这里部分代码省略.........
开发者ID:jfurlong,项目名称:BLIS,代码行数:101,代码来源:report_prevalence_agg.php

示例7: login

 public function login($username, $password)
 {
     print_r($_SESSION);
     global $con;
     $username = mysql_real_escape_string($username, $con);
     $saved_db = DbUtil::switchToGlobal();
     $password = encrypt_password($password);
     $query_string = "SELECT * FROM user " . "WHERE username='{$username}' " . "AND password='{$password}' AND lab_config_id != 0 LIMIT 1";
     $record = query_associative_one($query_string);
     # Return user profile (null if incorrect username/password)
     DbUtil::switchRestore($saved_db);
     //return User::getObject($record);
     if ($record == NULL) {
         return -1;
     } else {
         $tok = API::start_session($username, $password);
         return $tok;
     }
 }
开发者ID:caseyi,项目名称:BLIS,代码行数:19,代码来源:db_lib.php


注:本文中的DbUtil::switchToGlobal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。