On Fri, 2007-03-23 at 09:15 +0100, Németh Zoltán wrote: > // method 2 > $time = microtime(TRUE); > for ($i = 1; $i <= 5000; $i++) { > $done = FALSE; > while (!$done) { > $id = md5((microtime(TRUE) * (rand(1,1000) / 100))); > $sql = "INSERT INTO idtest (id,cnt) VALUES ('$id', $i)"; > $result = mysql_query($sql); > if ($result) { $done = TRUE; } > } > } > $end = microtime(TRUE) - $time; > echo "method 2 time: " . $end . "<br>"; One of the problems with the above style is that if the query fails for some other reason (typo, no permissions, database temporarily unavailable, etc) the code will run indefinitely (or until it gets killed for too much time). That's a very dirty way to manage failed inserts due to dupes. Cheers, Rob. -- .------------------------------------------------------------. | InterJinn Application Framework - http://www.interjinn.com | :------------------------------------------------------------: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `------------------------------------------------------------' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php