I need to save a series of values into a table and need help changing the database class
function save($data)
{
$row = $this->getTable();
//Convert data from a stdClass
if (get_class($data) == 'stdClass')
$data = JArrayHelper::fromObject($data);
//Current id if unspecified
if ($data['id'] != null)
$id = $data['id'];
else if (($this->_id != null) && ($this->_id > 0))
$id = $this->_id;
//Load the current object, in order to process an update
if (isset($id))
$row->load($id);
// Bind the form fields to the lockr table
$ignore = array();
if (!$row->bind($data, $ignore)) {
JError::raiseWarning(1000, $this->_db->getErrorMsg());
return false;
}
// Make sure the lockr table is valid
if (!$row->check()) {
JError::raiseWarning(1000, $this->_db->getErrorMsg());
return false;
}
// Store the lockr table to the database
if (!$row->store())
{
JError::raiseWarning(1000, $this->_db->getErrorMsg());
return false;
}
$this->_id = $row->id;
$this->_data = $row;
return true;
}
The field name is notes[], and I have javascript adding extra fields on the form (so the array could be 1 or 20+)
The database table that these values need to be saved to is #__lockr_drillnotes (which is not the main #__lockr_drills table that this save routine saves the rest of the data to)
I know that this needs to happen after the main save routine happens because I need to use the id from the other table as a foreign key to link the note to this drill.
Any ideas? If explaining this will take more time than you can spare, I am happy to pay for someone to customise this code.
Thank you all
Andy