Update field in another list

paralosreg

New Member
Hi. Im trying to update a field stored in another list when I send a form. I have a unique value to identify in both lists. I tried this code.

PHP:
$fecha='{fab_extintores_recargas___extintores_recargas_fecha_recarga}'; 
$extintor='{fab_extintores_recargas___extintores_recargas_extintores}';
$db =&JFactory::getDBO();
$db->setQuery("UPDATE fab_extintores SET fab_extintores___extintores_ultima_recarga = '$fecha' WHERE fab_extintores___extintores_numero = '$extintor'");
$db->query();
Many Thanks
 
Hello,

Try to echo the query, see if you get the right values in query. Depending on the type of elemente you might need to add _raw at the end of element placeholder
 
Where did you try that code? In a form PHP plugin? If so, what "hook" is it running on (like onAfterProcess, etc).

-- hugh
 
whilst fabrik uses full element names such as fab_extintores___extintores_ultima_recarga
the db field will be the element name -
extintores_ultima_recarga, so in your query replace the full element names with the element name
 
many thanks to everybody, especially rob. that was the problem. this is the good code "PHP onAfterProcess":

PHP:
$fecha='{fab_extintores_recargas___extintores_recargas_fecha_recarga}'; 
$extintor='{fab_extintores_recargas___extintores_recargas_extintores}';
$db =&JFactory::getDBO();
$db->setQuery("UPDATE fab_extintores SET extintores_ultima_recarga = '$fecha' WHERE extintores_numero = '$extintor'");
$db->query();
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top