public function make_tab($data,$tab)
{
$table_name = $tab;
$isTable = Db::query('SHOW TABLES LIKE ' . "'" . $table_name . "'");
if (!empty($isTable)) {
//表存在
//echo 1;
} else {
//表不存在
//echo 2;
$str = '';
foreach($data as $k=> $v){
$thisstr = "`".$k."` varchar(200) NOT NULL DEFAULT '' COMMENT '".$v."',";
$str = $str.$thisstr;
}
$sql = " CREATE TABLE IF NOT EXISTS `$table_name` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建和接收时间',
`update_time` int(11) NOT NULL DEFAULT '0' COMMENT '更新时间',
".$str."
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8 COMMENT='".$tab."信息';";
Db::execute($sql);//执行SQL生成表
}
return $table_name;
}