thinkphp 怎么查出一个数据库的表的所有数据
$goods = D(‘Goods’); //实例化Model对象,实际操作Goods数据表
$info = $goods – select(); //获得数据信息
print_r($info); //打印信息
怎么样用php显示数据库中的表列表
function list_tables($database)
{
$rs = mysql_query(“SHOW TABLES FROM $database”);
$tables = array();
while ($row = mysql_fetch_row($rs)) {
$tables[] = $row[0];
}
mysql_free_result($rs);
return $tables;
}
php mysqli 列出所有表和字段
$mysqli = new mysqli(‘localhost’,’my_user’,’my_password’,’world’); //连接数据库,需要换成对应的主机名,用户名,密码,数据库名
$result = $mysqli-query(‘SHOW TABLES’); //执行查询语句
$tables=array();
while($arr = $result-fetch_assoc()){
$tables[]=$arr; //遍历查询结果
}
$result = $mysqli-query(‘DESCRIBE table_name’); //table_name 换成你对应的表名
$column=array();
while($arr = $result-fetch_assoc()){
$column[]=$arr;
}
echo ‘pre’;
var_dump($tables); //输出所有表
var_dump($column); //输出所有字段
上面的例子没有对应的错误判断,大概思路是这样.