Hi, I'm trying to make a plugin to automatically assign default language data to an event's translation fields.
But I'm having issues getting any db operations to work.
I have no issues with performing db operations in layout overrides but here it seems nothing works.
So I was wondering if it's even possible to perform an update on the events table in an onAfterEventSave trigger?
For reference here the code for the plugin I'm trying to make, including a couple of the ways I've tried to perform the db operation.
Thank you in advance!
Code:
<?php
/**
* @package Joomla
* @subpackage Event Booking
*/
defined('_JEXEC') or die;
class plgCreateEventTranslations extends JPlugin
{
/**
* Application object.
*
* @var JApplicationCms
*/
protected $app;
/**
* Database object.
*
* @var JDatabaseDriver
*/
protected $db;
/**
* Create event translations with default language data
*
* @param EventbookingTableEvent $row
* @param array $data
* @param bool $isNew true if create new plan, false if edit
*/
public function onAfterSaveEvent($row, $data, $isNew)
{
$db = $this->db;
$query = $db->getQuery(true);
// QUERY METHOD ATTEMPT (USING QUERYBUILDER)
//$query->update('#__eb_events')
// ->set('title = ' . $db->quote('CHANGED'))
// ->where('id = ' . 468);
//$query->delete('#__eb_events')
// ->where('id = ' . (int) 468);
// QUERY METHOD ATTEMPT (USING RAW QUERY STRING)
$query = 'UPDATE #__eb_events SET short_description = "WORKSSS" WHERE id = 468';
$db->setQuery($query);
$db->execute();
// STORE METHOD ATTEMPT (USING ROW)
//$row->description = 'TESTESTEST';
//$row->store();
// STORE METHOD ATTEMPT (USING EVENT)
//$event = EventbookingHelperDatabase::getEvent(468);
//$event->title = 'ESTESTEST';
//$event->description = 'ESTESTEST';
//$event->store();
}
}