使用大型扩展插入将大型查询导入mysql数据库
问题描述:
Is there any program or script that can break down a extended insert (about 380,000 rows) into single SQL queries, my hosting isn't handling it and I found a script called Big Dump that imports single quires but it doesn't work for extended quires.
答
<?php
$lines = file('file.txt');
$count = count($lines);
$i = 0;
$query = "INSERT INTO table VALUES ";
foreach($lines as $line){
$i++;
if ($count == $i) {
$query .= "('".$line."')";
}
else{
$query .= "('".$line."'),";
}
}
mysql_query($query);
be sure it is not out of limit set in my.cnf