2017-04-14 179 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); 
}