I have an operation that will be run by cron, so I don't want it to be too heavy
As of now, It loops though everyone
Each time the file is run, the "Employees" gets 100% of the bosses income, divided amoung themselves. The bosses income does not include the bonus he gets from HIS boss.
0 means they have no boss
And of course, this would never happen in a real world senario.
Without the boss bonus, it is a simple
$sql="Update `table` SET `money`=`money`+`income`";However, I need to give the people with bosses x% of their bosses income
Employee 10000 gets his striaght income because he has no boss
Employee 10001 gets his income (50,000) PLUS his boss bonus. Since 10001 is the only one whos boss is 10000, he gets 100% (100,000). So he gets a total of 150,000
Employee 10002 gets his income (10,000) Plus his boss bonus. This time, there are two people who split it. He gets 50,000 / 2 = 25,000. His total is 35,000
Employee 10003 is the same as above, except he gets only 5,000 plus his 25,000 bonus.
I'm not really sure if this is possible, as it becomes multiple queries within a query....