Hi,
I have a table I created within the Joomla schema that I want to populate with data from a form, including some user data that's available to the form via the user plugin. In the past, I've used this code in the PHP plugin (at the start of form submission):
$myDb = JFactory::getDbo();
$userid = $formModel->getElementData('my_table___user_id',true);
$userid = is_array($userid) ? $userid[0] : $userid;
$myQuery = $myDb->getQuery(true);
$myQuery
->select(array('name', 'email'))
->from('joom01_users')
->where('id = ' . $myDb->quote($userid));
$myDb->setQuery($myQuery);
$row = $myDb->LoadObject();
$formModel->updateFormData('my_table___user_name', $row->name);
$formModel->updateFormData('my_table___email', $row->email);
return true;
It used to work fine. Under PHP 7.4 data are stored in the table (but not the ones filled in by this PHP fragment). Under PHP 8.0, I get a success message, but nothis is added to the table.
Is ther a simple way of doing this that will work under PHP 8?
I have a table I created within the Joomla schema that I want to populate with data from a form, including some user data that's available to the form via the user plugin. In the past, I've used this code in the PHP plugin (at the start of form submission):
$myDb = JFactory::getDbo();
$userid = $formModel->getElementData('my_table___user_id',true);
$userid = is_array($userid) ? $userid[0] : $userid;
$myQuery = $myDb->getQuery(true);
$myQuery
->select(array('name', 'email'))
->from('joom01_users')
->where('id = ' . $myDb->quote($userid));
$myDb->setQuery($myQuery);
$row = $myDb->LoadObject();
$formModel->updateFormData('my_table___user_name', $row->name);
$formModel->updateFormData('my_table___email', $row->email);
return true;
It used to work fine. Under PHP 7.4 data are stored in the table (but not the ones filled in by this PHP fragment). Under PHP 8.0, I get a success message, but nothis is added to the table.
Is ther a simple way of doing this that will work under PHP 8?