Вот код:
public function add_poselok($xml){
mysql_query("TRUNCATE TABLE `pos`") or die(mysql_error());
for($i=0;$i<=$this->cnt_pos;$i++){
foreach($xml->pos->item[$i] as $key => $value){
$this->pos_param[$key] = $value;
}
$sql = mysql_query("INSERT INTO `pos` SET
`row_id`='".$this->pos_param['row_id']."',
`lot`='".$this->pos_param['lot']."',
`lot_conv`='".$this->pos_param['lot_conv']."',
`pos_name`='".$this->pos_param['pos_name']."',
`pos_www`='".$this->pos_param['pos_www']."',
`pos_text`='".$this->pos_param['pos_text']."',
`geocode`='".$this->pos_param['geocode']."',
`way_type`='".$this->pos_param['way_type']."',
`from_MKAD`='".$this->pos_param['from_MKAD']."',
`rayon_type`='".$this->pos_param['rayon_type']."',
`np_type`='".$this->pos_param['np_type']."',
`area1`='".$this->pos_param['area1']."',
`param2`='".$this->pos_param['param2']."',
`param42`='".$this->pos_param['param42']."',
`param1`='".$this->pos_param['param1']."',
`param3`='".$this->pos_param['param3']."',
`param4`='".$this->pos_param['param4']."',
`param10`='".$this->pos_param['param10']."',
`param11`='".$this->pos_param['param11']."',
`param5`='".$this->pos_param['param5']."',
`param6`='".$this->pos_param['param6']."',
`param7`='".$this->pos_param['param7']."',
`param8`='".$this->pos_param['param8']."',
`param14`='".$this->pos_param['param14']."',
`text10`='".$this->pos_param['text10']."',
`text11`='".$this->pos_param['text11']."',
`text12`='".$this->pos_param['text12']."',
`check1`='".$this->pos_param['check1']."',
`text21`='".$this->pos_param['text21']."',
`check2`='".$this->pos_param['check2']."',
`text22`='".$this->pos_param['text22']."',
`check3`='".$this->pos_param['check3']."',
`param21`='".$this->pos_param['param21']."',
`text23`='".$this->pos_param['text23']."',
`check4`='".$this->pos_param['check4']."',
`param22`='".$this->pos_param['param22']."',
`text24`='".$this->pos_param['text24']."',
`check5`='".$this->pos_param['check5']."',
`text25`='".$this->pos_param['text25']."',
`check6`='".$this->pos_param['check6']."',
`text26`='".$this->pos_param['text26']."',
`check7`='".$this->pos_param['check7']."',
`text27`='".$this->pos_param['text27']."'") or die(mysql_error());
unset($this->pos_param);
}
}
Я думал сделать через вставку нескольких строк одним инсертом:
INSERT INTO table (id,name,...) VALUES (1,OOO,...), (2,PPP,...)....
Но у меня 100 поселков и получится ОЧЕНЬ большая строка! Как мускул быстрее обработает? Я читал что мускул будет дольше обрабатывать строку... Чем обработает 100 запросов.
В случае 2 столбцов я изменил количество обращений и стало работать быстрее, но там не такие строки:
public function add_gui($xml){
for($i=0;$i<=15;$i++){
if($i == 14){
continue;
}
$truncate = mysql_query("TRUNCATE TABLE `".$this->gui_ar[$i]."`") or die(mysql_error());
for($r=0;$r<=$this->cnt_gui[$i];$r++){
$this->gui[$i] .= "('".$xml->types->type[$i]->type[$r][id]."','".$xml->types->type[$i]->type[$r][name]."'),";
}
$this->gui[$i] = mb_substr($this->gui[$i], 0, -1);
$sql = mysql_query("INSERT INTO ".$this->gui_ar[$i]." (id,name) VALUES ".$this->gui[$i]."") or die(mysql_error());
}
}
_____________
[Подпись удалена модератором]