查询不插入。笨

时间:2018-02-08 13:26:26

标签: php codeigniter

我是codeigniter的新手,我正在尝试调试无效的插入代码,我似乎无法找到错误。根据codeigniter文档中的MVC指南,我认为代码很好。请帮帮我。

这是我的代码:

与视图关联的功能

function submit_details() {
        $fullname = $this->input->post('fullname');
        $names = explode(" ", $fullname);
        $firstname = $names[0];
        $lastname = $names[1];
        $email = $this->input->post('email');
        $country = $this->input->post('country');
        $password = $this->input->post('password');
        $password = $this->_encrypt_pass($password);
        $time = time();
        $activation = $this->_encrypt_pass($time . ' ' . $fullname);

        $new_user_data = array(
            'firstname' => $firstname,
            'lastname' => $lastname,
            'password' => $password,
            'email' => $email,
            'country' => $country,
            'activation' => $activation,
            'creationdate' => $time,
            'updatedate' => $time,
            'usertype' => 1,
            'status' => 0
        );

        if ($this->users->create_user($new_user_data)) {
            # Create User Default group
            $user = $this->users->get_user_by_email($email);

            $userid = $user->userid;
            $groupname = 'General';
            $groupdesc = 'General Group for contacts.';


            $group = array(
                'user' => $userid,
                'groupdesc' => $groupdesc,
                'groupname' => $groupname
            );

            $this->contacts_model->CreateContactGroup($group);

            // echo "Account creation for $fullname succesfull. An Activation link has been sent to your email ($email)account";
        }
        redirect('login', $msg = 'Account creation for $fullname succesfull. An Activation link has been sent to your email ($email)account');
    }

插入

的功能
function create_user($user) {
        $result = false;
        if (!$this->check_email_exists($user['email'])) {
            if ($this->send_activation_link($user)) {
                $this->db->insert('users', $user);
            }
            $result = true;
        }
        return $result;
    }

1 个答案:

答案 0 :(得分:0)

您能否告诉控制台上显示的错误

你在哪里加载模型?我猜你的模型是users.Load它在构造函数或autoload.php中可能你没有加载模型