private static function createEmptyPursesFor($userID) { $purse = new Purse(); $purse->setUserId($userID); $purse->setValue(0.0); $allCurrencies = Currency::getAll(); foreach ($allCurrencies as $currency) { $purse->setCurrencyId($currency['id']); $purse->insert(); } }
private static function getPurseOrMakeNew($userId, $curId) { $purse = self::getPurse($userId, $curId); if ($purse != null) { return $purse; } $purse = new Purse(); $purse->setCurrencyId($curId); $purse->setUserId($userId); $purse->setValue(0); $purse->insert(); $result = Purse::findBy(array('UID' => $userId, 'CurId' => $curId)); $purse->findById($result[0]['id']); return $purse; }