Sorry for my English
I update the database table from the model, getting the id of the current record and field values through the controller.
Everything is working fine:
Code:
function update_record(){
if (isset($_POST['id'])){
$id=$this->input->post('id');
$this->db->set('id', $id);
}
if (isset($_POST['date_doc'])){
$date_doc=$this->input->post('date_doc');
$this->db->set('date_doc', $date_doc);
}
if (isset($_POST['num_batch'])){
$num_batch=$this->input->post('num_batch');
$this->db->set('num_batch', $num_batch);
}
$this->db->where('id', $id);
$result=$this->db->update('doc_prod_request');
return $result;
}
I want to
get the form fields (their names = the names of the table fields)
and their values in the loop.
Something like this:
Code:
$fields = $this->db->list_fields('doc_prod_request');
foreach ($fields as $field)
{
if (isset($_POST[$field])){
$field=$this->input->post($field);
$this->db->set($field, $field);
}
}
But naturally, such a construction does not allow writing the assignment of values to variables:
Code:
$this->db->set($field, $field);
They are overwritten.
Tell me how this can be implemented.
Thanks in advance.