$tournaments = Doctrine_Query::create() ->select('b.buyin, b.rake, t.date, t.is_bounty, t.allows_rebuy, t.allows_addon, s.name, p.id') ->from('TournamentPlayerLink tpl') ->innerjoin('tpl.Tournament t') ->innerjoin('t.Buyin b') ->innerjoin('t.Site s') ->innerjoin('s.Players p') ->where('p.user_id = ?', $this->getUser()->getUserId()) ->addwhere('(t.is_bounty = true and tpl.bounty IS NULL) OR (t.allows_rebuy = true AND tpl.rebuys IS NULL) OR (t.allows_addon = true AND tpl.rebuys IS NULL)') ->orderby('t.date DESC');