当尝试通过单击提交按钮将值从字段集发送到数据库时,我收到以下错误“Error500: JTableUser::bind( NULL )” 。
我在模型中的保存功能如下所示:
public function save($data)
{
$userId = (!empty($data['id'])) ? $data['id'] : (int) $this->getState('user.id');
$user = new JUser($userId);
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables');
$table =& JTable::getInstance('User', 'JTable', array());
// Unset the username so it does not get overwritten
unset($data['username']);
// Unset the block so it does not get overwritten
unset($data['block']);
// Unset the sendEmail so it does not get overwritten
unset($data['sendEmail']);
// Bind the data.
if (!$table->bind($data)) {
$this->setError(JText::sprintf('USERS PROFILE BIND FAILED', $user->getError()));
return false;
}
// Load the users plugin group.
JPluginHelper::importPlugin('user');
// Null the user groups so they don't get overwritten
$user->groups = null;
// Store the data.
if (!$table->save()) {
$this->setError($user->getError());
return false;
}
return $user->id;
}`
$data 填写正确,"getInstance('User', 'JTable', array());"
工作正常。感谢您的关注,有人可以帮我解决我的问题吗?