
Hi, I need to update several records. but storing these data take time. I need to store them faster.
The first code I wrote for this was
foreach ($items as $key => $value)
{
$loan = new loan($key);
$loan -> setStatus($value);
$loan -> store();
}
This took 1.2s.
So then I wrote this
$statment = $db->prepare("UPDATE `loans` SET `status`=%s WHERE id=%i;");
foreach ($items as $key => $value)
{
$db->execute($statment,$value,$key);
}
This took 0.8s. but it's not enough So I wrote This one. But there is no diffrent between this and the upper one.
foreach ($items as $key => $value)
{
$sd .= "UPDATE `loans` SET `status`='$value' WHERE id=$key;";
}
$db->execute($sd);
Please, Give me some Help to make this faster.
Sorry for my bad English.
Thanks in Advance...