我收到以下错误“Error500:JTableUser :: bind( NULL )”,当尝试通过点击提交按钮从fieldset向数据库发送值时。
我在模型中的保存功能如下所示:
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());"
正常。
感谢您的关注,有人可以帮助我解决问题吗?
答案 0 :(得分:0)
迟到的回复,但我认为问题在于:
if (!$table->save())
因为JTable(3.2)中的save方法需要将绑定数据作为第一个参数,并且它没有得到任何东西。
由于您之前绑定了数据,您可能需要:
if (!$table->store())