This update query is not working and I've triple-checked the general syntax for the update queries in Joomla via the documentation..Here is the code from the controller-side:
public function approveAll() {
$input = JFactory::getApplication()->input;
$selectedEntries = $input->post->get('id', array(), 'array');
JArrayHelper::toInteger($selectedEntries);
$model = $this->getModel();
$model->approveSelectedEntries($selectedEntries);
$model->sendMeAnEmail('This is so broken');
$this->setRedirect(JRoute::_('index.php?option=com_awardadmin', false));
}
and here is the code from the model-side:
public function approveSelectedEntries($idsToApprove)
{
$db = JFactory::getDBO();
foreach ($idsToApprove as $currentID) {
$query = $db->getQuery(true);
$query->update('#__chronoforms_data_nominationForm');
$query->set('approved = 1');
//$query->set('approved = true');
$query->where('id = '.$currentID);
$db->setQuery($query);
//$db->loadRow();
$result = $db->execute();
$this->sendNotificationEmail($currentID);
sendMeAnEmail('IDs: '.$idsToApprove.'<br>ID: '.$currentID.'<br>Query: '.$query.'<br>DB: '.$db);
}
}
My experience with Joomla is limited but neither of my sendMeAnEmail methods are firing so something is getting lost somewhere and I don't know enough about how Joomla works to figure it out. I only have a basic understanding of how it applies MVC as well.
Any help would be appreciated.
The override for getModel():
public function getModel($name = 'Submission', $prefix = 'AwardAdminModel')
{
$model = parent::getModel($name, $prefix, array('ignore_request' => true));
return $model;
}
Tried changing the structure of the query as per this link to:
$fields = $db->quoteName('approved').' = true';
$conditions = $db->quoteName('id').' = 443';
$query->update($db->quoteName('#__chronoforms_data_nominationForm'))->set($fields)->where($conditions);
$db->setQuery($query);
$db->query();
But it did not work...even with hardcoded where clause.