`id` int(11) NOT NULL auto_increment,
`random1` varchar(100) default NULL,
`random2` varchar(100) default NULL,
`random3` varchar(100) default NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
Sample ouput:
http://www.angelcool.net/tutorials/othe ... 00rows.txt
<?php
set_time_limit(0);
function db_link()
{
//@ suppresses the error mysqli_connect returns, and instead we use our die() error
$db_link=mysqli_connect('127.0.0.1','root','');
if($db_link==false)
echo 'Could NOT connect to MySQL, check mysqli_connect settings. ';
//select database
if(@mysqli_select_db($db_link,'test')==false)
echo 'Could NOT select DB, check DB name.';
return $db_link;
}
function String()
{
//Step 1 Generate a token.
$length = 32;
$chars = 'ABCDEFGHIJKLMNPQRSTUVWXYZ123456789'; //ABCDEFGHIJKLMNPQRTWXYZ123456789 123456789abcdefghijklmnopqrstwxzABCDEFGHIJKLMNPQRTWXYZ
$string = '';
for ($i = 0; $i < $length; $i++) {
$pos = rand(0, strlen($chars)-1);
$string .= $chars{$pos}; }
return $string;
}
/*
How many different 4-letter combinations are there in the alphabet?
letters in alphabet = 26
Answer:
26^4 = 456,976
There are 26 choices for the first letter, 26 for the second, 26 for the 3rd and 26 for the 4th. So altogether, there are 26*26*26*26 = 456,976 combinations.
I hope this helps!
http://answers.yahoo.com/question/index ... 851AAkpgEj
*/
$conn=db_link();
echo '<b>'.date(DATE_RFC822).'</b>';
$execution_time=microtime(true);
for($iii=1;$iii<=200;)
{
$start=microtime(true);
/*
//Run this query to find out duplicate tokens
SELECT * FROM BulkTokens INNER JOIN (SELECT Token,COUNT(Token) AS Duplicated FROM BulkTokens
GROUP BY Token HAVING Duplicated > 1) dup ON BulkTokens.Token=dup.Token;
*/
$string1=String(); $string2=String(); $string3=String();
//Step 2 Check if token DOES NOT exist in database (check if it is duplicated, if it is skip this iteration).
// $query="SELECT random1 FROM RandomNumbers_InnoDB WHERE BINARY random1='".$string1."' and random2='".$string2."' and random3='".$string3."'";
// $result=mysqli_query($conn,$query) or die(mysqli_error($conn));
// $query=mysqli_num_rows($result);
//if token exists skip iteration.mysqli_num_rows($query)==0
if(true)//$query==0
{
//If token does not exist add 1 to $iii and assign the token to array.
// and insert it in database.
$query="INSERT INTO RandomNumbers_InnoDB(random1,random2,random3) VALUES('".$string1."','".$string2."','".$string3."');";
mysqli_query($conn,$query) or die(mysqli_error($conn));
echo $iii.'----'.$string1.'----'.$string2.'----'.$string3.' Iteration execution time:'.round((microtime(true)-$start),4).' secs<br>';
$iii++;
}
else
{ echo '====================================================================================================SKIPPED REPEATED RECORD !!';}
}
echo '<br><br><br>Total Execution Time:'.round((microtime(true)-$execution_time),4).'<br><br><br>';
echo '<b>'.date(DATE_RFC822).'</b>';
?>
Comments
Comments are not available for this entry.