I have a PHP foreach
statement, looping through a large number of $icons
.
For each icon, the DB-column sequence
needs to be updated. As follows:
foreach ($icons as $key => $icon) {
// MySql pseudo-code:
UPDATE `tbl_icon2album`
SET `sequence`= $key +1
WHERE iconID= $icon['id']
}
My problem: this becomes very slow for a large number of icons.
My question: Can I speed this up by executing one MySql command that would somehow include the foreach loop?
Much obliged...