return;
}
$inc = floor(DB_ORD_MAX / ($c + 1));
- $cur = $inc;
- foreach($ids as $id) {
- db_update($table, $field, $cur, 'where id=%i', $id);
- $cur += $inc;
+ $ord = $inc;
+ $count = count($ids);
+ for ($i = 0; $i < $count; $i += 1000) {
+ $values = [];
+ $j_max = min($count, $i + 1000);
+ for ($j = $i; $j < $j_max; ++$j) {
+ $id = $ids[$j];
+ $values[] = "($id,$ord)";
+ $ord += $inc;
+ }
+ $sql =
+ "insert into $table (id,$field) values "
+ . implode(',', $values)
+ . " on duplicate key update $field=VALUES($field)"
+ ;
+ db_send_query($sql);
}
}
}
if ($version === -1) {
- db_send_query('create table if not exists wfpl_mutexes (id int unique auto_increment, name varchar(30) binary, expires int(11)) CHARSET=utf8;');
+ db_send_query('create table if not exists wfpl_mutexes (id int unique auto_increment, name varchar(255) binary, expires int(11)) CHARSET=utf8;');
$version = 0;
# don't save version now in case another thread is doing this too
}