:)这个问题适合任何熟悉Tankauth插件的人 .
我编辑了tankauth,以便在没有电子邮件验证的情况下填充用户配置文件 .
在注册表单中,我添加并验证了另外两个名为“first_name”和“last_name”的字段,我希望在提交表单时将其添加到user_profiles表中 .
下面是tankauth函数,如果激活了用户,它将用户id添加到user_profiles表 . 我注释掉了($激活) . 问题是我不知道如何将新字段first_name和last_name插入db . 我一直在尝试任何错误 .
function create_user($data, $activated = TRUE)
{
$data['created'] = date('Y-m-d H:i:s');
$data['activated'] = $activated ? 1 : 0;
if ($this->db->insert($this->table_name, $data)) {
$user_id = $this->db->insert_id();
//if ($activated)
$this->create_profile($user_id);
return array(
'user_id' => $user_id,
'first_name' => $first_name, //added by me
'first_name' => $first_name, //added by me
);
}
return NULL;
}
以上是与之相关的
private function create_profile($user_id)
{
$this->db->set('user_id', $user_id);
$this->db->set('first_name', $first_name); //added by me
return $this->db->insert($this->profile_table_name);
}
有人可以分享一些指导吗?
1 回答
尝试删除
private function create_profile
中的private
您也可以将
create_profile
函数更改为:如果没有这些工作 . 尝试使用
echo $this->db->last_query();
希望有所帮助 .