티스토리 뷰

SWDesk/Web

[BDIY] Update DataTable

inhae 2021. 10. 4. 10:13

PHP Source Code

 

function UpdateDataTables($Conn){
	$Query1 = "select * from BDIY_UserInfos";
	$queryResult = mysqli_query($Conn, $Query1);
	$userList = array();
	$index1 = 0;
	while($Row1 = mysqli_fetch_array($queryResult)){
		$user1 = new cUserInfo();
		$user1->SetValuesfromRow($Row1);
		$userList[$index1] = $user1;
		$index1++;
	}
	echo "[Count-User] ".$index1."<br>";
	
	foreach($userList as $user1){
		$userCode = $user1->UserCode;
		$Query1 = "select * from BDIY_DeviceInfos WHERE UserCode='".$userCode."';";
		$queryResult = mysqli_query($Conn, $Query1);
		$deviceList = array();
		$index1 = 0;
		while($Row1 = mysqli_fetch_array($queryResult)){
			$device1 = new cDeviceInfo();
			$device1->SetValuesfromRow($Row1);
			$deviceList[$index1] = $device1;
			$index1++;
		}
		echo "[Count-".$userCode."] ".$index1."<br>";
		$device1 = $deviceList[0];
		$dataTablename = $device1->DataTable;
		$Query1 = "select count(*) as cnt from ".$dataTablename.";";
		$queryResult = mysqli_query($Conn, $Query1);
		while($Row1 = mysqli_fetch_array($queryResult)){
			$dataCount = $Row1['cnt'];
			echo "[".$dataTablename."] ".$dataCount."<br>";
		}
		if($dataCount > 3000000){
			$newTablename = $userCode."_NewData".date('Ym');
			$data1 = new cDataInfo($newTablename);
			$data1->CreateTable($Conn);
			foreach($deviceList as $device1){
				$device1->DataTable = $newTablename;
				$device1->UpdateData($Conn);
			}
		}
	}
반응형
반응형
250x250
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/01   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함