$link = mysql_connect('localhost', 'root', 'root');
mysql_select_db('temp');
$table = "article"; //指定表名
$query = 'SELECT * FROM '.$table;
$result = mysql_query($query);
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
$key = array();
$value = array();
foreach ($line as $k=$v) {
$key[] = $k;
$value[] = "'".str_replace("'", "'", $v)."'";
}
$sql[] = "INSERT INTO `".$table."`(".join(",", $key).") VALUES(".join(",", $value).");rn";
}
file_put_contents("sql/".$table."_sql.php", $sql);
mysql_free_result($result);
mysql_close($link);
?