So I need to create a function that is called every time a user completes an action, and then according to their action gives them exp points.
Currently I have something like this:
$this->db->query("INSERT INTO experience (userid, action, exp) VALUES (1, $some_action, $exp)");
Just wondering what the best way to keep track of what they’ve achieved and such? Also would it be okay to use the SUM function to calculate their exp according to these records? Or would it be too slow if there are a lot of records?
Thanks!
You should probably add a timestamp or datetime field, but yeah SUM would be the solution:
On a per-action breakdown: