Files
coolcoth.com/app/Views/admin/db_tables.php
T
2026-08-08 15:53:53 +08:00

50 lines
2.1 KiB
PHP

<?php /** @var array $tables @var int $total @var bool $fileMode @var array $dataFiles */ ?>
<div class="page-head">
<div>
<h1>数据库管理</h1>
<div class="desc">查看并维护数据库中所有表的数据,可进行浏览、编辑、新增与删除。</div>
</div>
<a class="btn-soft" href="<?php echo site_url('admin/upgrade'); ?>"><?php echo admin_icon('upload', 16); ?> 数据库升级</a>
</div>
<?php if (!empty($fileMode)): ?>
<div class="admin-card">
<div class="alert alert-warn">当前为 <b>文件存储模式</b>,不支持在线数据库管理。可用数据文件如下(只读):</div>
<table class="tbl">
<thead><tr><th>数据文件</th><th>大小</th></tr></thead>
<tbody>
<?php foreach (($dataFiles ?? []) as $f): ?>
<tr><td><?php echo e($f['name']); ?></td><td><?php echo number_format($f['size']); ?> B</td></tr>
<?php endforeach; ?>
<?php if (empty($dataFiles)): ?><tr><td colspan="2" class="muted">无数据文件</td></tr><?php endif; ?>
</tbody>
</table>
</div>
<?php else: ?>
<div class="admin-card">
<div class="db-stat">共 <b><?php echo (int)($total ?? 0); ?></b> 张表</div>
<div class="tbl-wrap">
<table class="tbl">
<thead>
<tr>
<th>表名</th><th>引擎</th><th class="num">记录数</th><th class="num">大小</th><th class="num">操作</th>
</tr>
</thead>
<tbody>
<?php foreach (($tables ?? []) as $t): ?>
<tr>
<td class="mono"><?php echo e($t['name']); ?></td>
<td class="muted"><?php echo e($t['engine']); ?></td>
<td class="num"><?php echo number_format($t['rows']); ?></td>
<td class="num"><?php echo human_size($t['size']); ?></td>
<td class="num">
<a class="link-ok" href="<?php echo site_url('admin/db/browse/' . $t['name']); ?>">浏览数据</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
<?php endif; ?>