Reputation: 1
Hi all here is a snippet of the function for my update record
public function updateRecord()
{
helper(['form', 'url']);
$model = new EmployeeModel();
$id = $this->request->getVar('emp_id');
echo $id;
$data = [
'emp_fname' => $this->request->getVar('emp_fname'),
'emp_lname' => $this->request->getVar('emp_lname'),
'emp_mname' => $this->request->getVar('emp_mname'),
'emp_status' => $this->request->getVar('emp_status'),
'emp_position' => $this->request->getVar('emp_position'),
];
$save = $model->update($id, $data);
return redirect()->to(base_url('display'));
}
Upvotes: 0
Views: 258
Reputation: 13
In your model change the primaryKey config option to your custom primary key name:
protected $primaryKey = 'emp_id';
https://codeigniter4.github.io/userguide/models/model.html#models
Upvotes: 1
Reputation: 1
I solved the issue, it seems that using a custom ID on the database does not work with the query statements in CI4.
I changed my emp_id to id in the database itself and it solved the issue.
Upvotes: 0