我想检查一个数据库并首先获取所有表名,然后从每个表中的数据显示某种报告
$query = $db3->query("SELECT `table_name` from INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'db3' ") or die("$db3->error");
while ( $table = $query->fetch_assoc() )
{
//echo $table['table_name'].'<br />';
$t = trim($table['table_name']);
//i get all table names now i want to select all columns from that table name :
$select = $db3->query("SELECT * FROM ".$t." ") or die($db3->error);
$row = $select->fetch_assoc();
// checking to see if query worked fine
echo gettype($row);
//it returns NULL
}
我做对了吗?
我该怎么办 ?
出于安全原因,您应该拥有要从其生成报告的数据库/表的白名单。查询所有表均假定所有将来的表都将成为该系统的一部分。
您可以使用show columns from tableName
并迭代结果来查询每个表中的列。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句