![]() 复制<?备表备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].";\n\n"; $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; } 1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.  |