- URL 하드코딩 → .env APP_URL 기반 동적 URL로 변경 - DB 연결 하드코딩 → .env 기반으로 변경 - MySQL strict mode DATE 오류 수정
121 lines
5.2 KiB
PHP
121 lines
5.2 KiB
PHP
<?php
|
|
// make의 자료를 output의 screenlist로 json형태로 저장된 자료를 변형하는 코드이다.
|
|
|
|
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
|
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
|
|
$pdo = db_connect(); // DB 연결 함수 호출
|
|
|
|
// 타임 리미트 설정
|
|
set_time_limit(0);
|
|
|
|
// 출력 버퍼링 비활성화
|
|
ob_implicit_flush(true);
|
|
|
|
// 디버깅을 위한 에러 출력 설정
|
|
ini_set('display_errors', 1);
|
|
ini_set('display_startup_errors', 1);
|
|
error_reporting(E_ALL);
|
|
|
|
print 'screenlist 일부값을 변경하기 <br>';
|
|
|
|
try {
|
|
// output 테이블에서 num 컬럼 가져오기
|
|
$output_sql = "SELECT num FROM chandj.output";
|
|
$output_stmt = $pdo->prepare($output_sql);
|
|
$output_stmt->execute();
|
|
$output_results = $output_stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
$total_rows = count($output_results);
|
|
$current_row = 0;
|
|
|
|
foreach ($output_results as $output_row) {
|
|
$output_num = $output_row['num'];
|
|
// make 테이블에서 outputnum이 같은 데이터를 가져오기
|
|
$make_sql = "SELECT `upnum`, `outputnum`, `num`, `text1`, `text2`, `text3`, `text4`, `text5`,
|
|
`ordercompany`, `callname`, `cutwidth`, `cutheight`, `number`, `printside`,
|
|
`direction`, `exititem`, `intervalnum`, `intervalnumsecond`, `memo`, `draw`,
|
|
`drawbottom1`, `drawbottom2`, `drawbottom3`, `exitinterval`, `cover`, `left_check`,
|
|
`mid_check`, `right_check`, `done_check`, `remain_check`
|
|
FROM chandj.make WHERE outputnum = :outputnum ORDER BY num ASC";
|
|
$make_stmt = $pdo->prepare($make_sql);
|
|
$make_stmt->bindParam(':outputnum', $output_num, PDO::PARAM_INT);
|
|
$make_stmt->execute();
|
|
$make_results = $make_stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
$screenlist_data = [];
|
|
|
|
if ($make_stmt->rowCount() > 0) {
|
|
// 각 make 테이블의 행을 배열로 추가
|
|
foreach ($make_results as $make_row) {
|
|
// '띄우고'를 '띄고'로 변경
|
|
$drawbottom1 = str_replace('띄우고', '띄고', $make_row['drawbottom1']);
|
|
$drawbottom2 = str_replace('띄우고', '띄고', $make_row['drawbottom2']);
|
|
$drawbottom3 = str_replace('띄우고', '띄고', $make_row['drawbottom3']);
|
|
|
|
// draw 필드에서 파일명만 추출
|
|
preg_match('/<img src="\.\.\/img\/screen\/(.+?)">/', $make_row['draw'], $matches);
|
|
$draw = $matches[1] ?? '';
|
|
|
|
$screenlist_data[] = [
|
|
'upnum' => $make_row['upnum'],
|
|
'outputnum' => $make_row['outputnum'],
|
|
'num' => $make_row['num'],
|
|
'text1' => $make_row['text1'],
|
|
'text2' => $make_row['text2'],
|
|
'text3' => $make_row['text3'],
|
|
'text4' => $make_row['text4'],
|
|
'text5' => $make_row['text5'],
|
|
'ordercompany' => $make_row['ordercompany'],
|
|
'callname' => $make_row['callname'],
|
|
'cutwidth' => $make_row['cutwidth'],
|
|
'cutheight' => $make_row['cutheight'],
|
|
'number' => $make_row['number'],
|
|
'printside' => $make_row['printside'],
|
|
'direction' => $make_row['direction'],
|
|
'exititem' => $make_row['exititem'],
|
|
'intervalnum' => $make_row['intervalnum'],
|
|
'intervalnumsecond' => $make_row['intervalnumsecond'],
|
|
'memo' => $make_row['memo'],
|
|
'draw' => $draw,
|
|
'drawbottom1' => $drawbottom1,
|
|
'drawbottom2' => $drawbottom2,
|
|
'drawbottom3' => $drawbottom3,
|
|
'exitinterval' => $make_row['exitinterval'],
|
|
'cover' => $make_row['cover'],
|
|
'left_check' => $make_row['left_check'],
|
|
'mid_check' => $make_row['mid_check'],
|
|
'right_check' => $make_row['right_check'],
|
|
'done_check' => $make_row['done_check'],
|
|
'remain_check' => $make_row['remain_check']
|
|
];
|
|
}
|
|
}
|
|
|
|
// JSON으로 인코딩
|
|
$screenlist_json = json_encode($screenlist_data, JSON_UNESCAPED_UNICODE);
|
|
|
|
// output 테이블의 screenlist 업데이트
|
|
$update_sql = "UPDATE chandj.output SET screenlist = :screenlist WHERE num = :num";
|
|
$update_stmt = $pdo->prepare($update_sql);
|
|
$update_stmt->bindParam(':screenlist', $screenlist_json, PDO::PARAM_STR);
|
|
$update_stmt->bindParam(':num', $output_num, PDO::PARAM_INT);
|
|
if (!$update_stmt->execute()) {
|
|
echo "Error updating record for num $output_num: " . implode(", ", $update_stmt->errorInfo()) . "<br>";
|
|
}
|
|
|
|
// 진행 상황 출력
|
|
$current_row++;
|
|
echo "Processed rows: $current_row<br>";
|
|
if ($current_row % 100 == 0) {
|
|
echo "Processed $current_row of $total_rows rows<br>";
|
|
}
|
|
}
|
|
|
|
echo "Finished processing all records.";
|
|
} catch (PDOException $e) {
|
|
echo "Error: " . $e->getMessage();
|
|
}
|
|
?>
|
|
</body>
|
|
</html>
|