Codeigniter : I can't update data in a database

时间:2017-06-15 09:25:51

标签: php codeigniter-3

I can't update data in a database.i don't know what happend.please help me. Display data Press the edit button.But i can not edit data on the database.

I have posted the code below:

Controller.php

 public function ajax_edit($id)
{
    $data = $this->tblplace->get_by_id($id);
    echo json_encode($data);
}

public function ajax_update()
{
    $data = array(
      'placename' => $this->input->post('placename'),
      'description' => $this->input->post('description'),
      'tel' => $this->input->post('tel'),   
      'latitude' => $this->input->post('latitude'),
      'longtitude' => $this->input->post('longtitude'),
      'placetype_id' => $this->input->post('placetype_id'),
      'province_id' => $this->input->post('province_id')
      );
    $this->tblplace->update(array('placeid' => $this->input->post('placeid')), $data);
    echo json_encode(array("status" => TRUE));
}

Model.php

public function save($data)
{
    $this->db->insert('tblplace', $data);
    return $this->db->insert_id();
}

public function update($where, $data)
{
    $this->db->update('tblplace', $data, $where);
    return $this->db->affected_rows();
}

I need to help.Thank you.

0 个答案:

没有答案