title: Checking if a query's result exists in Joomla php function?
body: <p>I've created a function in Joomla. It checks if the given user's id exists in the database's table with an 'IF' statement. I think there's something wrong with the condition I'm using for the 'IF' statement.</p>
  
  <p>Here's the code:</p>
  
  <pre><code>    public function setRemainingPoints($userId,$points_taken) 
      {
      $db     =&amp; JFactory::getDBO();
  
      $query  =   ' SELECT '
                 .$db-&gt;nameQuote('remaining_points').' FROM '
                 .$db-&gt;nameQuote('#__remainingpoints').' WHERE '
                 .$db-&gt;nameQuote('user_id').'='.$userId;  
  
      $db-&gt;setQuery( $query );
  
      if ($result = $db-&gt;query()) 
      {               
      /* code if user found */
      }
      else
      {
      /* code if user not found */
      }   
      return true;
      }
  </code></pre>
  
  <p><em>Thanks in advance.</em></p>