以下的文章主要向大家介绍的是MySQL备份之根据表备份,该篇文章主要是以实际应用代码的方式来引出MySQL备份之根据表备份,下面就是文章的主要内容描述,IT技术网itjs.cn整理分享给学习MySQL的朋友,希望大家喜欢这样的Mysql文章或资料。
< php function datatosql($table) { global $db; $tabledump = "DROP TABLE IF EXISTS $table;n"; $createtable = $db->query("SHOW CREATE TABLE $table"); $create = $db->fetch_array($createtable); $tabledump .= $create[1].";nn"; $rows = $db->query("SELECT * FROM $table"); $numfields = $db->num_fields($rows); $numrows = $db->num_rows($rows); while ($row = $db->fetch_array($rows)){ $comma = ""; $tabledump .= "INSERT INTO $table VALUES("; for($i = 0; $i < $numfields; $i++) { $tabledump .= $comma."'".MySQL_escape_string($row[$i])."'"; $comma = ","; } $tabledump .= ");n"; } $tabledump .= "n"; return $tabledump; }
上面说了这么多内容,是关于对MySQL备份之-根据表备份的介绍,不知道各位对MySQL的认识是不是更上一层楼了,时时关注ITJS,学习最新Mysql技术。 上面说了这么多内容,是关于对MySQL备份之-根据表备份的介绍,不知道各位对MySQL的认识是不是更上一层楼了,时时关注ITJS,学习最新Mysql技术。