View Single Post
Old 02-18-2007, 03:37 AM  
tical
Confirmed User
 
Join Date: Feb 2002
Location: Las Vegas
Posts: 6,504
try this query instead, should be WAY faster... only hits MySQL once with a large insert

(note: that last substr just removes the trailing "," from the query so its valid)

Code:
	$dbcnx = mysql_connect('localhost','xxxxx', 'xxxxx'); 
	mysql_select_db("testtable", $dbcnx); 
	$query = "";
	for ($i = 10000; $i <= 20000; $i++) {
		$query = $query . "('" . $i . "'),";
	}
	$query = "insert into users (muser) values " . substr($query, 0, strlen($query) - 1);
	mysql_query($query);
i think thats right, but you get the idea... you can do multiple inserts in one query w/ MySQL so handle the processing beforehand and eliminate all the redundant connections, etc.
__________________
112.020.756
tical is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote