How to clean a lead...
 
Notifications
Clear all

How to clean a leaderboard without deleting it?

3 Posts
2 Users
0 Reactions
1,369 Views
(@danilletov)
Posts: 13
Eminent Member
Topic starter
 

Hello,

Every month I need to clear the leaderboard and start fixing the players rating again. Is it possible to do this without deleting the table completely?

This topic was modified 6 years ago by DanilLetov
 
Posted : 28/02/2019 12:29 pm
(@skaredcreations)
Posts: 805
Prominent Member Admin
 

You can execute a query to delete all records of a single leaderboard from the table LeaderBoard_User:

DELETE FROM LeaderBoard_User WHERE IdLeaderboard = 123456;

If you can create a job schedule on your server (Cronjob on Linux or Scheduled Task on Windows) then you could also create a small PHP script to be executed once per day at 00:00, for example create a file /combu/_services/empty_leaderboard.php:

<?php

include '../lib/api.php';

use Combu\LeaderBoard_User;

// Delete all scores of a leaderboard on day '1' of every month
if (intval(date("d")) === 1) {
    $query = "DELETE FROM " . LeaderBoard_User::GetTableName(LeaderBoard_User::class) . " WHERE IdLeaderboard = 123456";
    $Database->Query($query);
}

FRANCESCO CROCETTI @ SKARED CREATIONS

 
Posted : 28/02/2019 6:51 pm
(@danilletov)
Posts: 13
Eminent Member
Topic starter
 

Thank you very much!
You really helped.

 
Posted : 28/02/2019 7:51 pm
Share: