Quote:
Originally Posted by Phalynx
|
noch eine kleine speicheroptimierung (das ganze mit query_first() also limit 1 und automatischem free(). beachte die verwendung der variablen $att statt $attq; userid habe ich gleich mit entfernt, wird nicht ben?tigt):
Code:
if (($att = $vbulletin->db->query_first("
SELECT (_wr * " . (int) $vbulletin->options['vbsoccer_points']['wr'] . ") +
((_count - _wr - _rr - _rd) * " . (int) $vbulletin->options['vbsoccer_points']['rw'] . ") +
(_rd * " . (int) $vbulletin->options['vbsoccer_points']['rd'] . ") +
(_rr * " . (int) $vbulletin->options['vbsoccer_points']['rr'] . ") AS points
FROM (
SELECT userid, COUNT(*) AS _count,
SUM(score_key != bet_score_key) AS _wr,
SUM(bet_home=points_home AND bet_away=points_away) AS _rr,
SUM(CAST(bet_home - bet_away AS SIGNED)=(points_home - points_away)
AND NOT (bet_home = points_home AND bet_away = points_away)) AS _rd
FROM " . TABLE_PREFIX . "soccer_user_bet AS b
INNER JOIN " . TABLE_PREFIX . "soccer_match AS m ON(m.id=b.match_id)
WHERE userid=" . $user['userid'] . " AND score_key>0 AND match_is_finished=1
GROUP BY userid) AS userpoints
")))
{
$xperience['count_user_vbs'] = $att['points'] * $vbulletin->options['xperience_points_vbs'];
$xperience['count_user'] += $xperience['count_user_vbs'];
}