The table #__virtuemart_order_histories stores the orders with their virtuemart_order_ids and every order has the records with their own virtuemart_order_history_ids. I need to update the latest record in the range of certain order. Now I have the code:
$order_id = 1028;
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$fields = array($db->quoteName('order_status_code') . " = " . $db->quote('U'));
$conditions = array($db->quoteName('virtuemart_order_id') . " = " . $order_id);
$query->update($db->quoteName('#__virtuemart_order_histories'))->set($fields)->where($conditions)->order($db->quoteName('virtuemart_order_history_id') . ' DESC');
$db->setQuery($query);
$db->execute($query);
But it doesn't work how I need — it updates ALL the records of certain order and not only the latest one. How should I specify the condition of getting only the latest record?