How can I improve this code? I wanted to know if there's a possibility to remove the for
loop, and UPDATE
a different uniqueID
for each ID
in my database.
<?php
$reponse = $bdd->prepare("SELECT MAX(ID) FROM tuto WHERE title=''");
$reponse->execute();
$IDnow = $reponse->fetch(PDO::FETCH_ASSOC);
$IDnow = $IDnow['MAX(ID)'];
for ($i=2 ; $i <= $IDnow ; $i++){
$reponse = $bdd->prepare("UPDATE tuto SET uniqueID=:uniqueID WHERE uniqueID='' AND title='' AND ID=:i");
$uniqueID = $donnees['uniqueID'];
$int = rand(0,51);
$a_z = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
$uniqueID = time().$a_z[$int];
$reponse->execute([':uniqueID' => $uniqueID, 'i' => $i]);
}
?>
RAND()
\$\endgroup\$