首页 > 数据库技术 > 详细

MySQL备份之根据表备份概述

时间:2018-12-30 01:56:24      阅读:195      评论:0      收藏:0      [点我收藏+]

以下的文章主要向大家介绍的是MySQL备份之根据表备份,本文主要是以实际应用代码的方式来引出MySQL备份之根据表备份,下面就是文章的主要内容描述,希望会给你带来一些帮助在此方面。

  1. <?php 
  2. function datatosql($table)   
  3. {   
  4. global $db;   
  5. $tabledump = "DROP TABLE IF EXISTS $table;\n";   
  6. $createtable = $db->query("SHOW CREATE TABLE $table");   
  7. $create = $db->fetch_array($createtable);   
  8. $tabledump .= $create[1].";\n\n";   
  9. $rows = $db->query("SELECT * FROM $table");   
  10. $numfields = $db->num_fields($rows);   
  11. $numrows = $db->num_rows($rows);   
  12. while ($row = $db->fetch_array($rows)){   
  13. $comma = "";   
  14. $tabledump .= "INSERT INTO $table VALUES(";   
  15. for($i = 0; $i < $numfields; $i++)   
  16. {   
  17. $tabledump .= $comma."‘".MySQL_escape_string($row[$i])."‘";   
  18. $comma = ",";   
  19. }   
  20. $tabledump .= ");\n";   
  21. }   
  22. $tabledump .= "\n";   
  23. return $tabledump;   
  24. }  

以上的相关内容就是对MySQL备份之-根据表备份的介绍,望你能有所收获。

技术分享图片

以上的相关内容就是对MySQL备份之-根据表备份的介绍,望你能有所收获。

MySQL备份之根据表备份概述

原文:https://www.cnblogs.com/syncnavigator/p/10198267.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!