Level system in a gamification platform Currently, I'm working on gamification platform and I have the following rules for achieving a new level:


Level 0: When user registers
Level 1: When user confirms account
Level 2: When user completes a quiz
Level 3: When user completes a mission and publish more than 5 comments in the blog
Level 4: When user completes more than two missions and completes a campaign (campaign means donating money for something)
Level 5: Raised at least $50 in campaigns and complete at least two campaigns


Now, I have the following database where I'll keep a track of each user action (e.g. complete_quiz, complete_mission, etc.):

Achievements


id (int)
event (varchar)
amount (int) # used when event has specific value, e.g. money for complete_campaign event
user_id (int)
date_created (int)


When the user make any action (e.g. complete_mission), I'll insert the action in the table above and will call the following method to check if user has new level unlocked:

public function checkIfAchievmentUnlocksNewLevel($userObj)
{       
    $currentLevel = $userObj-&gt;level;

    $nextLevel = ++$currentLevel

    $isLevelUnlocked = false;

    switch($nextLevel)
    {
        case 0:
        case 1:
            // Each registered user will have these levels by default.
        break;
        case 2:
            $completedQuiz = $this-&gt;db-&gt;select("SELECT " . $this-&gt;fieldsList . " FROM " . $this-&gt;table . " WHERE event = :event AND user_id = :user_id ", array(':event' =&gt; 'complete_quiz', ':user_id' =&gt; $userObj-&gt;id));
            $isLevelUnlocked = count($completedQuiz) ? true : false;
        break;
        case 3:
            $completedMissions = $this-&gt;db-&gt;select("SELECT " . $this-&gt;fieldsList . " FROM " . $this-&gt;table . " WHERE event = :event AND user_id = :user_id", array(':event' =&gt; 'complete_mission', ':user_id' =&gt; $userObj-&gt;id));
            $wildwireComments = $this-&gt;db-&gt;select("SELECT " . $this-&gt;fieldsList ." FROM " . $this-&gt;table . " WHERE event = :event AND user_id = :user_id", array(':event' =&gt; 'wildwire_comment', ':user_id' =&gt; $userObj-&gt;id));              
            $isLevelUnlocked = (count($completedMissions) &amp;&amp; count($wildwireComments) &gt;= 5) ? true : false;
        break;
        case 4:
            $completedMissions = $this-&gt;db-&gt;select("SELECT " . $this-&gt;fieldsList . " FROM " . $this-&gt;table . " WHERE event = :event AND user_id = :user_id", array(':event' =&gt; 'complete_mission', ':user_id' =&gt; $userObj-&gt;id));
            $completedCampaigns = $this-&gt;db-&gt;select("SELECT " . $this-&gt;fieldsList ." FROM " . $this-&gt;table . " WHERE event = :event AND user_id = :user_id", array(':event' =&gt; 'complete_campaign', ':user_id' =&gt; $userObj-&gt;id));
            $isLevelUnlocked = (count($completedMissions) &gt;= 2 &amp;&amp; count($completedCampaigns)) ? true : false;
        break;
        case 5:
            $campaignRaisedMoney = $this-&gt;db-&gt;select("SELECT SUM(amount) FROM " . $this-&gt;table . " WHERE event = :event AND user_id = :user_id", array(':event' =&gt; 'complete_campaign', ':user_id' =&gt; $userObj-&gt;id));
            $completedCampaigns = $this-&gt;db-&gt;select("SELECT " . $this-&gt;fieldsList ." FROM " . $this-&gt;table . " WHERE event = :event AND user_id = :user_id", array(':event' =&gt; 'complete_campaign', ':user_id' =&gt; $userObj-&gt;id));
            $isLevelUnlocked = (count($compaignRaisedMoney) &gt;= 50.00 &amp;&amp; count($completedCampaigns) &gt;= 2) ? true : false;
        break;
    }

    if($isLevelUnlocked) 
    {
        $userHelper-&gt;setLevel($nextLevel);
    }

}


This code is working now, but I want to refactor it and am looking for any suggestions on how to improve it.
I would agree with @ardaozkal that an XP based system would be better (more flexible, etc).

But assuming that your approach is good enough for your situation, I also have some suggestions:


You have quite a bit of duplication, for example the completed mission queries or the completed campaign queries. You should extract those to their own function and reuse that.
Your code could generally benefit from more functions. Other candidates would be hasCompletexXMissions($db, $amount) or getCompletedMissionCount($db). 
If this project is a bit more complex, you definitely want to add classes, such as Mission, which may then contain the functions mentioned above.
Your lines are too long, which seriously impacts readability. 226 characters don't even fit on many modern screens. I would aim for about 80 characters.
You have a bit too much vertical whitespace for my taste. Do the first three statements really all need their own paragraph?
You can get rid of $currentLevel, it's only used in one location, and the name doesn't really add any value. Just use $userObj-&gt;level directly.