Location: PHPKode > scripts > multipleInsert > multipleinsert/multipleInsert.inc
<?php
/*
#####################################################################
# File Name : multipleInsert.inc
# Author : Alok Mohanty
# Last Modify : May 28,2003
# License : GPL
# Contact Info
# E-Mail : hide@address.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);
	}
}
?>
Return current item: multipleInsert