초기 커밋: 5130 레거시 시스템
- URL 하드코딩 → .env APP_URL 기반 동적 URL로 변경 - DB 연결 하드코딩 → .env 기반으로 변경 - MySQL strict mode DATE 오류 수정
This commit is contained in:
41
work/insert_check.php
Normal file
41
work/insert_check.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
||||
|
||||
// 기본 설정
|
||||
$mode = isset($_REQUEST['mode']) ? $_REQUEST['mode'] : '';
|
||||
$num = isset($_REQUEST['num']) ? $_REQUEST['num'] : '';
|
||||
$checkstep = isset($_POST['checkstep']) ? $_POST['checkstep'] : '';
|
||||
$update_log = isset($_POST['update_log']) ? $_POST['update_log'] : '';
|
||||
|
||||
header("Content-Type: application/json");
|
||||
// include '_request.php';
|
||||
|
||||
$tablename = 'work';
|
||||
|
||||
// checkstep이 전달된 경우 업데이트 로직
|
||||
if ($mode == "modify") {
|
||||
require_once("../lib/mydb.php");
|
||||
$pdo = db_connect();
|
||||
|
||||
try {
|
||||
// 트랜잭션 시작
|
||||
$pdo->beginTransaction();
|
||||
$update_log = date("Y-m-d H:i:s") . " - " . $_SESSION["name"] . " " . $update_log . "
";
|
||||
|
||||
// checkstep 업데이트 쿼리
|
||||
$sql = "UPDATE $DB.$tablename SET checkstep = ?, update_log =? WHERE num = ? LIMIT 1";
|
||||
$stmh = $pdo->prepare($sql);
|
||||
$stmh->execute([$checkstep, $update_log, $num]);
|
||||
|
||||
// 커밋
|
||||
$pdo->commit();
|
||||
|
||||
echo json_encode(['success' => true, 'checkstep' => $checkstep]);
|
||||
} catch (PDOException $Exception) {
|
||||
// 롤백 및 에러 메시지 반환
|
||||
$pdo->rollBack();
|
||||
echo json_encode(['error' => $Exception->getMessage()]);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user