I am new to Joomla and received a half-done component. It is a mostly database-dependent component. The component consists of a SQL file that inserts all the data and is able to display it. I am trying to build the function to insert into database on click. In the model, I have created a function:
public function addDefault(){
$db = JFactory::getDbo();
$insert = $db->getQuery(true);
$columns = array(`code`);
$values = array(`1`);
$insert
->insert($db->quoteName('#__mc_masterclass'))
->columns($db->quoteName($columns))
->values(implode(',', $values));
return $db->setQuery($insert)->execute();
}
And now I am trying to fire it from view:
button onclick="addDefault()">SAVE<button
I am not sure if I need to build something in the controller folder as well.
The function is very basic and simple just to get connection between the page and database.