2017-04-14 148 views
0

你好大家我是新的codeigniter我试图在数据库中插入数据,但不能正常工作,但不插入数据在数据库中。我是激活助手和自动加载是我写。codeigniter数据没有插入数据库

我控制器

public function save() { 
    if($this->input->post('submit')) { 
     $this->Checkout_model->process();     
    } 
} 

我的模型

function process() { 
    $name = $this->input->post('name'); 
    $phone = $this->input->post('phone'); 
    $email = $this->input->post('email'); 
    $address = $this->input->post('address'); 
    $data=array (
     'name' => $name, 
     'phone' => $phone, 
     'email' => $email, 
     'address' => $address    
    ); 
    $this->db->insert('customers',$data); 
} 
+1

显示何种类型的错误 –

+0

显示时没有错误,但也未保存在数据库中 – maulik

回答

1

使用此代码在控制器

public function save() { 
    if($this->input->post('submit')) { 
    $name = $this->input->post('name'); 
    $phone = $this->input->post('phone'); 
    $email = $this->input->post('email'); 
    $address = $this->input->post('address'); 
    $data=array (
     'name' => $name, 
     'phone' => $phone, 
     'email' => $email, 
     'address' => $address    
    ); 
     $this->Checkout_model->process($data);     
    } 
} 

在型号

function process($data) { 
    $this->db->insert('customers',$data); 
}