I have a database table named users
There are two columns in this table (which are important)
uuid and parentUuid
Here are the rules for the table:
- If the user invites another user, the invited user column
parentUuidis equal to the uuidinvitation. - If the user was not invited, their column
parentUuid:null - There can be endless user levels.
What I want to do is create a function function counter($levels, $uuid){}
When the counter is called (say $ levels = 3)
I want the function to return an array that looks like
array(0 => 200, 1 => 600, 2 => 1800);
So, the main idea is that I want it to count, for $levelslevels, how many users are in the tree under the user.
What is the best way to do this?