Quote:
Originally Posted by budgie
also this will not work on seedbox and home pc torrents On cleanups
you will get DB locks on it via mysqli it will only work on PHP 5.6 NOT 7.0 SO ON
PHP Code:
$fields = explode(":", "comments:leechers:seeders");
$res = sql_query("SELECT id, seeders, leechers, comments FROM torrents");
while ($row = mysqli_fetch_assoc($res)) {
$id = $row["id"];
$torr = $torrents[$id];
foreach ($fields as $field) {
if (!isset($torr[$field]))
$torr[$field] = 0;
}
$update = array();
foreach ($fields as $field) {
if ($torr[$field] != $row[$field])
$update[] = "$field = " . $torr[$field];
}
if (count($update))
sql_query("UPDATE torrents SET " . implode(",", $update) . " WHERE id = $id");
}
|
Which query gives the lock? Is your table myisam or innodb?
MyISAM locks the entire table on update, InnoDB on locks the effected rows.