/** * Constructor * Find the balance from the most recent transaction. * If no balance is found, create an initial transaction. * * @param object &$db Database * @param integer $uid User ID * @return void */ public function __construct(&$db, $uid) { $this->_db = $db; $this->uid = $uid; $BA = new Account($this->_db); if ($BA->load_uid($this->uid)) { $this->balance = $BA->balance; $this->earnings = $BA->earnings; $this->credit = $BA->credit; } else { // no points are given initially $this->balance = 0; $this->earnings = 0; $this->credit = 0; $this->_saveBalance('creation'); } }