读取mysql一个库下面的所有的表table
我们先来看代码:
<?php require 'class/db.php'; $sql = "select * from information_schema.tables where table_schema='ecshop' and table_type='base table' order by table_rows desc "; $arr = $db->queryarray($sql); //var_dump($arr); foreach ($arr as $k => $v) { $tbname = $v->table_name; $rows = $v->table_rows; echo $tbname.' - '; echo $rows; echo '<br>'; } ?>
table_name 表名字
table_rows 表记录数量
data_length 数据长度。
["table_catalog"]=>
null
["table_schema"]=>
string(10) “leo_ecshop”
["table_name"]=>
string(9) “ecs_goods”
["table_type"]=>
string(10) “base table”
["engine"]=>
string(6) “myisam”
["version"]=>
string(2) “10″
["row_format"]=>
string(7) “dynamic”
["table_rows"]=>
string(1) “7″
["avg_row_length"]=>
string(3) “286″
["data_length"]=>
string(4) “2008″
["max_data_length"]=>
string(15) “281474976710655″
["index_length"]=>
string(5) “11264″
["data_free"]=>
string(1) “0″
["auto_increment"]=>
string(1) “8″
["create_time"]=>
string(19) “2016-11-15 22:27:40″
["update_time"]=>
string(19) “2016-12-04 11:25:55″
["check_time"]=>
string(19) “2016-12-04 11:19:50″
["table_collation"]=>
string(15) “utf8_general_ci”
["checksum"]=>
null
["create_options"]=>
string(0) “”
["table_comment"]=>
string(0) “”