Hi,
as usual 405hp is always the best.
at
Welcome to the PHP Classes Repository - PHP Classes
i found this class
PHP Code:
<?php
/*
#####################################################################
# File Name : multipleInsert.inc
# Author : Alok Mohanty
# Last Modify : May 28,2003
# License : GPL
# Contact Info
# E-Mail : alok_r_mohanty@yahoo.com
######################################################################
*/
/*
This class is used for inserting multiple rows in a single query.
*/
class multiInsert
{
var $table;
var $fields;
var $data;
function multiInsert($v_table,$v_fields,$v_data)
{
$this->table = $v_table;
$this->fields = $v_fields;
$this->data = $v_data;
}
function generateQuery()
{
for($i=0;$i<count($this->data);$i++)
{
$query_arr[] = ' (\''.implode ("','", $this->data[$i]).'\') ';
}
return "INSERT INTO ".$this->table."(".implode (",", $this->fields).") VALUES ".implode (",",$query_arr);
}
}
?>
so the loop for insert begin:
PHP Code:
if ($rec_count == 0) {
for ($n = 1 ; $n <= $max ; $n++){
$c1 = GUID();
for ($k = 0 ; $k < $max_arr; $k++) {
$j = ($n-1)*$max_arr+$k;
$t = $arr[$j];
$a = $values[$t];
$v1 = $a[0];
$v2 = $a[1];
$data_arr[$j][] = $v1;
$data_arr[$j][] = $v2;
$data_arr[$j][] = $c1;
$data_arr[$j][] = $c2;
$data_arr[$j][] = $c3;
$data_arr[$j][] = $c4;
$data_arr[$j][] = $c5;
}
}
$dbname = $this->dboutlet4you1->DatabaseName ; // MYSQL DataBase Name
$dbhost = $this->dboutlet4you1->Host; // MYSQL Host Name
$dbuser = $this->dboutlet4you1->UserName; // User Name
$dbpwd = $this->dboutlet4you1->UserPassword ; // Password
$link = mysql_connect($dbhost, $dbuser, $dbpwd) or die ("unable to connect");
mysql_select_db($dbname,$link)or die("could not select database") ;
$table_desn = 'dest_table'; // Destination Table
$field_arr_desn = Array( v1,
v2,
c1,
c2,
c3,
c4,
c5);
$MI = new multiInsert($table_desn,$field_arr_desn,$data_arr);
$requiredQuery = $MI->generateQuery();
mysql_query($requiredQuery) or die(mysql_error());
and now it work perfect and very fast.
Many thank for the help.
Have a good day.