php查找所有表 字段+注释
public function chaxun()
{
$sql = "show tables";
$re = Db::query($sql);
$data = [];
foreach ($re as $index => $item) {
$table = $item['Tables_in_lingyuan'];
$data = Db::query('SHOW FULL COLUMNS FROM ' . $table);
echo '<center>';
echo "<h1>表名{$item['Tables_in_lingyuan']}</h1>";
echo '<table class="biao" border="1"><tr><td>字段名</td><td>字段类型</td><td>是否为空 no为不可 yes为可以</td><td>字段名 翻译注释</td><td>字段默认值</td></tr>';
foreach ($data as $k => $v) {
echo
"<tr class='dropdown'>
<td>{$v['Field']}</td> " . "
<td>{$v['Type']} </td> " . "
<td>{$v['Null']} </td> " . "
<td>{$v['Comment']} </td> " . "
<td>{$v['Default']} </td> " . "
</tr>";
}
echo '</table>';
echo '</center>';
}
exit();
$table = "think_goods";
$data = Db::query('SHOW FULL COLUMNS FROM ' . $table);
echo '<center>';
echo '<table class="biao" border="1"><tr><td>字段名</td><td>字段类型</td><td>是否为空 no为不可 yes为可以</td><td>字段名 翻译注释</td><td>字段默认值</td></tr>';
foreach ($data as $k => $v) {
echo
"<tr class='dropdown'>
<td>{$v['Field']}</td> " . "
<td>{$v['Type']} </td> " . "
<td>{$v['Null']} </td> " . "
<td>{$v['Comment']} </td> " . "
<td>{$v['Default']} </td> " . "
</tr>";
}
echo '</table>';
echo '</center>';
exit();
}
|