Massive MySQL queries
Posted: Tue Aug 01, 2006 4:10 pm
feyd | Please use
the $i variable is just to keep the $pw and $login values the same as the $un values. This of course does one mysql_query per array element in the $un array. I am fairly new to sql/php and am not sure if there is a better way to enter large amounts of data. This method takes a long time to execute, if anyone knows how I could speed the process up I would greatly appreciate it.
-sneaky
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi, this is my first post on this forum. I am trying to add large amounts of data to an sql database using php. The fields being added have 3 columns and anywere from 1,000 to 10,000 rows. The primary key for each field is set to auto increment. The way I am doing it right now is this:Code: Select all
$i = 0;
foreach($un as $val){
mysql_query("INSERT INTO database(un,pw,login) VALUES('$val','$pw[$i]','$login[$i]')") or die(mysql_error());
$i++;
}-sneaky
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]