Commit 1dcf9fcf46562f459e47d6e8563b39432efe02bb
1 parent
3cc7a772
fix: use correct column bound_at in admin portal
Showing
1 changed file
with
7 additions
and
5 deletions
| @@ -41,7 +41,8 @@ if ($pdo && $_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && | @@ -41,7 +41,8 @@ if ($pdo && $_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && | ||
| 41 | $check->execute([$user['id'], $deviceId]); | 41 | $check->execute([$user['id'], $deviceId]); |
| 42 | 42 | ||
| 43 | if (!$check->fetch()) { | 43 | if (!$check->fetch()) { |
| 44 | - $bind = $pdo->prepare("INSERT INTO user_device_bindings (user_id, device_id, is_primary, created_at) VALUES (?, ?, ?, NOW())"); | 44 | + // FIX: use 'bound_at' instead of 'created_at' |
| 45 | + $bind = $pdo->prepare("INSERT INTO user_device_bindings (user_id, device_id, is_primary, bound_at) VALUES (?, ?, ?, NOW())"); | ||
| 45 | $bind->execute([$user['id'], $deviceId, $isPrimary]); | 46 | $bind->execute([$user['id'], $deviceId, $isPrimary]); |
| 46 | $message = "<div style='color: green; margin-bottom: 20px; background: #e6fffa; padding: 10px; border-radius: 4px;'>✅ 成功将设备 <b>$deviceId</b> 绑定给用户 <b>{$user['nickname']}</b></div>"; | 47 | $message = "<div style='color: green; margin-bottom: 20px; background: #e6fffa; padding: 10px; border-radius: 4px;'>✅ 成功将设备 <b>$deviceId</b> 绑定给用户 <b>{$user['nickname']}</b></div>"; |
| 47 | } else { | 48 | } else { |
| @@ -56,15 +57,16 @@ if ($pdo && $_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && | @@ -56,15 +57,16 @@ if ($pdo && $_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && | ||
| 56 | } | 57 | } |
| 57 | } | 58 | } |
| 58 | 59 | ||
| 59 | -// 获取设备列表 (Mock Data + Binding Count) | 60 | +// 获取设备列表 |
| 60 | $bindings = []; | 61 | $bindings = []; |
| 61 | if ($pdo) { | 62 | if ($pdo) { |
| 62 | try { | 63 | try { |
| 64 | + // FIX: use 'bound_at' instead of 'created_at' | ||
| 63 | $bindings = $pdo->query(" | 65 | $bindings = $pdo->query(" |
| 64 | - SELECT b.id, u.nickname, u.phone, b.device_id, b.is_primary, b.created_at | 66 | + SELECT b.id, u.nickname, u.phone, b.device_id, b.is_primary, b.bound_at |
| 65 | FROM user_device_bindings b | 67 | FROM user_device_bindings b |
| 66 | JOIN users u ON b.user_id = u.id | 68 | JOIN users u ON b.user_id = u.id |
| 67 | - ORDER BY b.created_at DESC | 69 | + ORDER BY b.bound_at DESC |
| 68 | ")->fetchAll(PDO::FETCH_ASSOC); | 70 | ")->fetchAll(PDO::FETCH_ASSOC); |
| 69 | } catch (Exception $e) { | 71 | } catch (Exception $e) { |
| 70 | if (empty($message)) | 72 | if (empty($message)) |
| @@ -152,7 +154,7 @@ if ($pdo) { | @@ -152,7 +154,7 @@ if ($pdo) { | ||
| 152 | <span style="color: var(--primary-color);">✔</span> | 154 | <span style="color: var(--primary-color);">✔</span> |
| 153 | <?php endif; ?> | 155 | <?php endif; ?> |
| 154 | </td> | 156 | </td> |
| 155 | - <td><?php echo $row['created_at']; ?></td> | 157 | + <td><?php echo $row['bound_at']; ?></td> |
| 156 | <td> | 158 | <td> |
| 157 | <a href="#" style="color: red; font-size: 12px; text-decoration: none;">解绑</a> | 159 | <a href="#" style="color: red; font-size: 12px; text-decoration: none;">解绑</a> |
| 158 | </td> | 160 | </td> |
Please
register
or
login
to post a comment