Files
edu/bbs/myclass/_back/_tmp_index_diag.php

125 lines
5.2 KiB
PHP

<?php
/**
* _tmp_index_diag.php — index.php 영상 로딩 진단
* 확인 후 삭제할 임시 파일
*/
header('Content-Type: text/html; charset=utf-8');
require_once __DIR__ . '/db_conn.php';
$pdo = db_conn();
echo '<h2>EDU 인덱스 영상 로딩 진단</h2>';
echo '<style>table{border-collapse:collapse;margin:10px 0} td,th{border:1px solid #ccc;padding:4px 8px} .ok{color:green} .err{color:red} .warn{color:orange}</style>';
// 1. 테이블 목록 확인
echo '<h3>1. 관련 테이블 존재 여부</h3>';
$tables = $pdo->query("SHOW TABLES")->fetchAll(PDO::FETCH_COLUMN);
$checkTables = ['edu_contents','edu_content_keywords','edu_keywords','edu_users','edu_user_keywords','edu_codes'];
echo '<table><tr><th>테이블명</th><th>존재</th><th>레코드 수</th></tr>';
foreach ($checkTables as $tbl) {
$exists = in_array($tbl, $tables);
$count = 0;
if ($exists) {
$count = $pdo->query("SELECT COUNT(*) FROM `$tbl`")->fetchColumn();
}
$cls = $exists ? 'ok' : 'err';
echo "<tr><td>$tbl</td><td class='$cls'>" . ($exists ? '✔' : '✘ 없음') . "</td><td>$count</td></tr>";
}
echo '</table>';
// 2. edu_contents 컬럼 구조
echo '<h3>2. edu_contents 컬럼 구조</h3>';
if (in_array('edu_contents', $tables)) {
$cols = $pdo->query("SHOW COLUMNS FROM edu_contents")->fetchAll();
echo '<table><tr><th>Field</th><th>Type</th><th>Null</th><th>Key</th><th>Default</th></tr>';
foreach ($cols as $c) {
echo "<tr><td>{$c['Field']}</td><td>{$c['Type']}</td><td>{$c['Null']}</td><td>{$c['Key']}</td><td>{$c['Default']}</td></tr>";
}
echo '</table>';
// 샘플 데이터 3건
echo '<h3>2-1. edu_contents 샘플 (최대 5건)</h3>';
$rows = $pdo->query("SELECT * FROM edu_contents LIMIT 5")->fetchAll();
if ($rows) {
$keys = array_keys($rows[0]);
echo '<table><tr>' . implode('', array_map(fn($k) => "<th>$k</th>", $keys)) . '</tr>';
foreach ($rows as $r) {
echo '<tr>' . implode('', array_map(fn($v) => '<td>' . htmlspecialchars((string)$v) . '</td>', $r)) . '</tr>';
}
echo '</table>';
} else {
echo '<p class="err">⚠ edu_contents 에 데이터가 없습니다 (DB 초기화됨)</p>';
}
} else {
echo '<p class="err">edu_contents 테이블이 존재하지 않습니다.</p>';
}
// 3. edu_content_keywords 구조 & 샘플
echo '<h3>3. edu_content_keywords (키워드-콘텐츠 매핑)</h3>';
if (in_array('edu_content_keywords', $tables)) {
$cols = $pdo->query("SHOW COLUMNS FROM edu_content_keywords")->fetchAll();
echo '<table><tr><th>Field</th><th>Type</th></tr>';
foreach ($cols as $c) {
echo "<tr><td>{$c['Field']}</td><td>{$c['Type']}</td></tr>";
}
echo '</table>';
$rows = $pdo->query("SELECT * FROM edu_content_keywords LIMIT 5")->fetchAll();
if ($rows) {
$keys = array_keys($rows[0]);
echo '<table><tr>' . implode('', array_map(fn($k) => "<th>$k</th>", $keys)) . '</tr>';
foreach ($rows as $r) {
echo '<tr>' . implode('', array_map(fn($v) => '<td>' . htmlspecialchars((string)$v) . '</td>', $r)) . '</tr>';
}
echo '</table>';
} else {
echo '<p class="warn">edu_content_keywords 에 데이터가 없습니다.</p>';
}
} else {
echo '<p class="warn">edu_content_keywords 테이블이 없습니다.</p>';
}
// 4. edu_keywords 구조 & 샘플
echo '<h3>4. edu_keywords</h3>';
if (in_array('edu_keywords', $tables)) {
$rows = $pdo->query("SELECT * FROM edu_keywords LIMIT 10")->fetchAll();
if ($rows) {
$keys = array_keys($rows[0]);
echo '<table><tr>' . implode('', array_map(fn($k) => "<th>$k</th>", $keys)) . '</tr>';
foreach ($rows as $r) {
echo '<tr>' . implode('', array_map(fn($v) => '<td>' . htmlspecialchars((string)$v) . '</td>', $r)) . '</tr>';
}
echo '</table>';
} else {
echo '<p class="warn">edu_keywords 에 데이터가 없습니다.</p>';
}
} else {
echo '<p class="warn">edu_keywords 테이블이 없습니다.</p>';
}
// 5. edu_user_keywords (유저-키워드 연결)
echo '<h3>5. edu_user_keywords</h3>';
if (in_array('edu_user_keywords', $tables)) {
$cols = $pdo->query("SHOW COLUMNS FROM edu_user_keywords")->fetchAll();
echo '<table><tr><th>Field</th><th>Type</th></tr>';
foreach ($cols as $c) {
echo "<tr><td>{$c['Field']}</td><td>{$c['Type']}</td></tr>";
}
echo '</table>';
$rows = $pdo->query("SELECT * FROM edu_user_keywords LIMIT 10")->fetchAll();
if ($rows) {
$keys = array_keys($rows[0]);
echo '<table><tr>' . implode('', array_map(fn($k) => "<th>$k</th>", $keys)) . '</tr>';
foreach ($rows as $r) {
echo '<tr>' . implode('', array_map(fn($v) => '<td>' . htmlspecialchars((string)$v) . '</td>', $r)) . '</tr>';
}
echo '</table>';
} else {
echo '<p class="warn">edu_user_keywords 에 데이터가 없습니다.</p>';
}
} else {
echo '<p class="warn">edu_user_keywords 테이블이 없습니다.</p>';
}
// 6. 전체 테이블 목록
echo '<h3>6. DB 전체 테이블 목록 (' . count($tables) . '개)</h3>';
echo '<ul>' . implode('', array_map(fn($t) => "<li>$t</li>", $tables)) . '</ul>';