1. //执行命令获取建表的语句
    2. $sql = "show create table user";
    3. $db->query($sql);
    4. //获取语句
    5. foreach ($data as $v) {
    6. $name = 'Create Table';
    7. $new = $v->$a;
    8. break;
    9. }
    1. //获取数据的inster 语句
    2. $sql = "select * from user";
    3. $data=$db->query($sql);
    4. $insert='';
    5. foreach ($data as $vslye){
    6. $field=$value='';
    7. foreach ($vslye as $v=>$k){
    8. $field .= empty($field) ? $v : ',' . $v;
    9. $value .= empty($value) ? "'$k'" : ",'$k'";
    10. }
    11. $insert.="INSERT INTO `user` ($field) VALUES ($value);";
    12. }