I'm looping through an array and for each record generating unique identifier with uniqid
:
foreach($emailsByCampaign as $campaign => $emails) {
$campaignHex = $this->strToHex($campaign);
$values = "(";
for ($i=0; $i<sizeof($emails);$i++) {
$values .= $analyticsDbInstance->escape($emails[$i]) . ",'" . uniqid(true) . "'), (";
}
}
Official documentation states that uniqid
generates id
based on microseconds. What is the likely that two cycles of the loop will pass in less than two seconds which will lead to not unique ids?