mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-08-29 14:47:14 +00:00
refactor: enclosing many updates into transaction for speed improvement
#313
This commit is contained in:
@@ -604,11 +604,14 @@ class Automation {
|
|||||||
|
|
||||||
// update what's needed
|
// update what's needed
|
||||||
$timeNow = time();
|
$timeNow = time();
|
||||||
|
|
||||||
|
mysqli_begin_transaction($GLOBALS['link']);
|
||||||
foreach ($ownerDatas as $record) {
|
foreach ($ownerDatas as $record) {
|
||||||
$cp = $record['Total'] * ( $timeNow - $record['lastupdate'] ) / $dur_day;
|
$cp = $record['Total'] * ( $timeNow - $record['lastupdate'] ) / $dur_day;
|
||||||
$q = "UPDATE " . TB_PREFIX . "users set cp = cp + $cp, lastupdate = $timeNow where id = " . $record['owner'];
|
$q = "UPDATE " . TB_PREFIX . "users set cp = cp + $cp, lastupdate = $timeNow where id = " . $record['owner'];
|
||||||
$database->query( $q );
|
$database->query( $q );
|
||||||
}
|
}
|
||||||
|
mysqli_commit($GLOBALS['link']);
|
||||||
|
|
||||||
if(file_exists("GameEngine/Prevention/culturepoints.txt")) {
|
if(file_exists("GameEngine/Prevention/culturepoints.txt")) {
|
||||||
unlink("GameEngine/Prevention/culturepoints.txt");
|
unlink("GameEngine/Prevention/culturepoints.txt");
|
||||||
|
|||||||
Reference in New Issue
Block a user