[英]codeigniter data is not insert into database
大家好,我是codeigniter的新手,我試圖在數據庫中插入數據,但無法正常工作。但是沒有在database.In中插入數據。
我的控制器
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);
}
在控制器中使用此代碼
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);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.