I'm trying to write this query:
SET @rownumber = 0;
UPDATE #__hikers SET rank = (@rownumber:=@rownumber+1)
ORDER BY score DESC;
like JDatabaseQuery, but still got an error. Please help
UPDATE: I tried this code 1:
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->set($db->quote(@rownumber = 0));
$query->update($db->quoteName('#__hikers'));
$query->set($db->quoteName('#__rank''rank') . ' = ' .$db->quote(@rownumber:=@rownumber+1));
$query->order('score DESC');
$db->setQuery($query);
$result = $db->execute();
code 2:
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->set($db->quote(@rownumber).' = '.$db->quote (0));
$query->update($db->quoteName('#__hikers'));
$query->set($db->quoteName('#__rank''rank') .' = '.$db->quote(@rownumber).' = '. $db->quote(@rownumber).' + '. $db->quote(1));
$query->order('score DESC');
$db->setQuery($query);
$result = $db->execute();