exec("SET NAMES 'utf8mb4'"); $sql = " SELECT lh.content_id, lh.comment, lh.last_viewed_at, c.title, c.category_code, c.category_group, u.name FROM edu_learning_histories lh INNER JOIN edu_contents c ON c.content_id = lh.content_id INNER JOIN edu_users u ON u.member_id = lh.member_id AND u.sys_comp_code = lh.sys_comp_code WHERE lh.member_id = :member_id AND lh.sys_comp_code = :sys_comp_code AND c.category_code = 'CA10001' -- 마이클래스 AND lh.comment IS NOT NULL AND TRIM(lh.comment) <> '' ORDER BY lh.last_viewed_at DESC LIMIT 20 "; $stmt = $pdo->prepare($sql); $stmt->execute([ ':member_id' => $memberId, ':sys_comp_code' => $sysCompCode, ]); foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) { $myCommentList[] = [ 'content_id' => $row['content_id'], 'title' => $row['title'], 'comment' => $row['comment'], 'member_name' => $row['name'], 'last_viewed_at' => $row['last_viewed_at'], 'date_dot' => !empty($row['last_viewed_at']) ? date('y.m.d', strtotime($row['last_viewed_at'])) : '', ]; } } catch (Throwable $e) { // 운영 시 로깅 권장 }