42 lines
986 B
PHP
42 lines
986 B
PHP
<?php
|
|
header('Content-Type: application/json; charset=utf-8');
|
|
require_once '../../bbs/db_conn.php';
|
|
|
|
// PDO 연결 생성
|
|
$pdo = db_conn();
|
|
|
|
try {
|
|
$base_year = $_GET['base_year'] ?? '';
|
|
|
|
if (empty($base_year)) {
|
|
echo json_encode(['start_date' => '', 'end_date' => '']);
|
|
exit;
|
|
}
|
|
|
|
$stmt = $pdo->prepare("
|
|
SELECT start_date, end_date
|
|
FROM edu_contents
|
|
WHERE category_code = 'CA10003'
|
|
AND base_year = ?
|
|
GROUP BY start_date, end_date
|
|
ORDER BY start_date DESC, end_date DESC
|
|
LIMIT 1
|
|
");
|
|
|
|
$stmt->execute([$base_year]);
|
|
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
|
|
if ($result) {
|
|
echo json_encode([
|
|
'start_date' => $result['start_date'],
|
|
'end_date' => $result['end_date']
|
|
]);
|
|
} else {
|
|
echo json_encode(['start_date' => '', 'end_date' => '']);
|
|
}
|
|
|
|
} catch (Exception $e) {
|
|
echo json_encode(['error' => $e->getMessage()]);
|
|
}
|
|
?>
|