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.
Here’s the code:
public function setRemainingPoints($userId,$points_taken)
{
$db =& JFactory::getDBO();
$query = ' SELECT '
.$db->nameQuote('remaining_points').' FROM '
.$db->nameQuote('#__remainingpoints').' WHERE '
.$db->nameQuote('user_id').'='.$userId;
$db->setQuery( $query );
if ($result = $db->query())
{
/* code if user found */
}
else
{
/* code if user not found */
}
return true;
}
Thanks in advance.
You need to get its number rows and make condition in this way