Good evening. For learning purposes I am building a CRUD script with the possibility for drag and drop rows using ajax. While sending the data from the controller to the model, my model function is unable to treat the array so I am encountering a problem.
Controller function:
public function from_ajax() {
$this->load->model('model');
$ordem = $this->input->post('ordem');
parse_str($ordem, $array_ordenado);
var_dump($array_ordenado); //testing only
$resultado = $this->model->reordem($array_ordenado);
echo json_encode($resultado);
}
var_dump on controller output:
array(1) { ["teste"]=> array(4) { [0]=> string(1) "1" [1]=> string(1) "3" [2]=> string(1) "2" [3]=> string(1) "4" } }
Here is my model function:
public function reordem($data) {
$this->db->select('page_order');
$this->db->from('tbl_posts');
return $this->db->update('tbl_posts', $data);
}
How would I treat this array dump on my model function so I can get the value I want (the ones inside "")?
I'm also getting this error: php/database error Thank you for your time!