1

我遇到了这个错误,导致我的脚本执行时间比平时要长。我试图通过类似错误的帖子,但我从中得到的建议是分配更多或无限的内存大小,其他人声称这些内存大小可能会在未来引起问题。我尝试检查我的 XAMPP 控制面板,发现有一个错误“未以管理员身份登录”,所以我修复了该错误,但内存错误仍然无法修复,我尝试查看我的代码,但一切似乎都很好,因为系统应该使用一个表单来将数据插入和更新到数据库中,当然它会这样做,但执行时间比平时要长。我搞砸了我的代码,或者有没有办法解决这个问题,而不是通过分配更多或无限的内存来作弊?我在 Windows 7 上使用 CodeIgniter。任何帮助将不胜感激,在此先感谢。在下面找到我的代码片段。 N/B:将函数 update_institution_contact_info() 视为虚拟函数,因为我还没有研究过它,它在那里描绘了要实现的想法。

控制器 - vetting.php

    public function create_institution_contact_info()
{
    $data['main_content'] = 'institution_contact_info_view';
    $data['method'] = 'create_institution_contact_info';
    $this->load->model('institution_users_model');
    $data['form_data'] = $this->institution_users_model->get_institution_contact_info();
    $data['title'] = 'Institution Contact Information';
    $this->load->view('includes/template', $data);

    $this->form_validation->set_rules(
        'institution_registration_no', 
        'Institution Registration Number', 
        'trim|required|is_unique[institution_contact_info.institution_registration_no]'
    );
    $this->form_validation->set_rules('institution_address', 'Institution Address', 'trim|required');
    $this->form_validation->set_rules('institution_telephone_no', 'Institution Telephone Number', 'trim|required');

    if($this->form_validation->run()){
        //$this->load->model('institution_users_model');
        $create_institution_contact = $this->institution_users_model->create_institution_contact(); 

        if($create_institution_contact)
        {
            redirect('vetting/basic_info');
        }
        else
        {
            $this->create_institution_contact_info();
        }
    }
    else
    {
        $this->create_institution_contact_info();
    }

}

public function update_institution_contact_info()
{
    $data['main_content'] = 'institution_contact_info_view';
    $data['method'] = 'update_institution_contact_info';
    $this->load->model('institution_users_model');
    $data['form_data'] = $this->institution_users_model->get_institution_contact_info();
    $data['title'] = 'Update Institution Contact Information';
    $this->load->view('includes/template', $data);

    $this->form_validation->set_rules(
        'institution_registration_no', 
        'Institution Registration Number', 
        'trim|required|is_unique[institution_contact_info.institution_registration_no]'
    );
    $this->form_validation->set_rules('institution_address', 'Institution Address', 'trim|required');
    $this->form_validation->set_rules('institution_telephone_no', 'Institution Telephone Number', 'trim|required');

    if($this->form_validation->run()){
        //$this->load->model('institution_users_model');
        $create_institution_contact = $this->institution_users_model->create_institution_contact(); 

        if($create_institution_contact)
        {
            redirect('vetting/basic_info');
        }
        else
        {
            $this->create_institution_contact_info();
        }
    }
    else
    {
        $this->create_institution_contact_info();
    }

}

模型-institution_users_model.php

    public function get_institution_users_id() 
{
    //Get each logged_in user's current session_id
    $email_address = $this->session->userdata('email_address');
    if($email_address){
        $this->db->where('institution_users.email_address', $email_address);
        $institution_users = $this->db->get('institution_users');   
        foreach($institution_users->result() as $row)
        {
            $institution_users_id = $row->institution_users_id;
        }
        return $institution_users_id;
    }       
}

public function create_institution_contact()
{                               
    $contact_data = array(
        'institution_users_id' => $this->get_institution_users_id(),
        'institution_registration_no' => $this->input->post('institution_registration_no'),
        'institution_address' => $this->input->post('institution_address'),
        'institution_telephone_no' => $this->input->post('institution_telephone_no'),
        'website' => $this->input->post('website')
    );

    $insert_contact = $this->db->insert('institution_contact_info', $contact_data);
    if($insert_contact)
    {
        return true;
    }
    else
    {
        return false;
    }
} 

public function get_institution_contact_info()
{
    $this->db->where('institution_contact_info.institution_users_id', $this->get_institution_users_id());
    $institution_contact_info = $this->db->get('institution_contact_info');
    if($institution_contact_info->num_rows()>0)
    {
        $row = $institution_contact_info->row();
        return $row;
    }               
} 

查看-institution_contact_info.php

            <div class="form">

            <?php echo validation_errors(); ?>
            <form method="post" action="vetting/<?php echo $method; ?>">
                <label for="institution_registration_no">Institution Registration Number</label>
                <input type="text" name="institution_registration_no" value="<?php if(isset($form_data->institution_registration_no)){ echo $form_data->institution_registration_no; } ?>" />
                <label for="institution_address">Address/Location</label>
                <input type="text" name="institution_address" />
                <label for="institution_telephone_no">Institution Telephone Number</label>
                <input type="text" name="institution_telephone_no" />
                <label for="website">Website</label>
                <input type="text" name="website" />
                <input type="submit" name="next_submit" value="NEXT" data-theme="a" data-corners="false" />                                                         
            </form>
        </div>
4

0 回答 0