title: If statement that checks select query is being ignored
body: <p>I got the following code:</p>
  
  <pre><code>if(isset($_POST['vote'])){
  
          if (!$wgUser-&gt;isLoggedIn()) {
              // User is not online, don't accept the vote, set error message
              $msg = 'Login required to vote.';
          } if ($wgUser-&gt;isBlocked()) {
              // User is banned, don't accept the vote, set error message
              $msg = 'Account is banned.';
          } else {
              // User is online and not banned
              $buildId = htmlspecialchars($_POST['id'], ENT_QUOTES, 'UTF-8');
              $rating = htmlspecialchars($_POST['rating'], ENT_QUOTES, 'UTF-8');
              $comment = htmlspecialchars($_POST['comment'], ENT_QUOTES, 'UTF-8');
              $res = $db-&gt;select(
                  'build_rating',
                  array('article_id', 'username', 'vote', 'comment', 'date'),
                  array('article_id' =&gt; $buildId, 'username' =&gt; $wgUser-&gt;getName()),
                  __METHOD__
              );
  
              // Did user already vote on this build?
              if (!$res) {
                  // Yes, let's update the vote and set success message
                  $db-&gt;update(
                      'build_rating',
                      array('vote' =&gt; $rating, 'comment' =&gt; $comment),
                      array('article_id' =&gt; $buildId, 'username' =&gt; $wgUser-&gt;getName()),
                      __METHOD__
                  );
                  $msg = 'Your vote has been successfully updated.';
  
              } else {
                  // No, let's insert the vote and set success message
                  $db-&gt;insert(
                      'build_rating',
                      array('article_id' =&gt; $buildId, 'username' =&gt; $wgUser-&gt;getName(), 'vote' =&gt; $rating, 'comment' =&gt; $comment),
                      __METHOD__
                  );
                  $msg = 'Your vote has been successfully saved.';
              }
          }
      }
  </code></pre>
  
  <p>that is suposed to save a users rating on a specific article. Everything seems to be working correctly besides the if statements that check whether the user has already voted (in that case it should just update the rating) or if it's a brand new vote (in that case it should save it as a new vote). For some reason the if statements don't work since each vote is being saved as a new vote. A user can simply place 100 votes when he should in fact only be able to place just one per article. Could someone point out my error?</p>