PHP Form Plugin don't work

csim

Member
Hello,

I've this PHP Form Plugin (Frontend and Backend , Modify, onAfterProcess) :
PHP:
defined('_JEXEC') or die();
$publie = $formModel->formData['publie'];
$id = $formModel->formData['id'];
if ($publie == 0)
{
$db = JFactory::getDbo();


$query = $db->getQuery(true);
$query->clear();
$query->update('produits')->set('publie_prod = 0')->where('id = ' . (int) $id);
$db->setQuery($query);
$db->execute();
$db->commit();
}
When I display $publie and $id, the values are correct. When I display erros from db, I have no errors.
I have checked that the query is correct in database.
However the query is not performed.

Have you got an idea ?
Best Regards
 
Try:
PHP:
$db = JFactory::getDbo();
$query = $db->getQuery(true);
// Fields to update.
$fields = array(
    $db->quoteName('publie_prod') . ' = 0'
);
// Conditions for which records should be updated.
$conditions = array(
    $db->quoteName('id') . ' = ' . $db->quote($id)
);
$query->update($db->quoteName('produits'))->set($fields)->where($conditions);
$db->setQuery($query);
$result = $db->execute();
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top