Hi All
I'm using this code to get the value from previous record in a list sorted by placeholder {fab_datatester___fly_reg_raw} eg different last record depending on the place holders value.
This works fine.
But the problem is, it only works correct for adding new records, if an existing record is edited in any field the calc element is calculated again using the new "wrong" value and not the previous value.
How can I solve this?
Best regards
Thomas
I'm using this code to get the value from previous record in a list sorted by placeholder {fab_datatester___fly_reg_raw} eg different last record depending on the place holders value.
This works fine.
But the problem is, it only works correct for adding new records, if an existing record is edited in any field the calc element is calculated again using the new "wrong" value and not the previous value.
Code:
$db = JFactory::getDbo();
$query = $db->getQuery(true);
// selecting the tacho_slut field
$query->select('tacho_slut');
// from table fab_master_flyvedata
$query->from($db->quoteName('fab_master_flyvedata'));
//sorting the result by fly_reg placeholder id
$query->where($db->quoteName('fly_reg')." = ".$db->quote({fab_datatester___fly_reg_raw}));
// getting the last record
$query->order($db->quoteName('landings_tid'). 'desc LIMIT 1');
$db->setQuery($query);
return $db->loadResult();
How can I solve this?
Best regards
Thomas