Problem sending array from Controller to Model in Codeigniter

Problem sending array from Controller to Model in Codeigniter

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.

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!

php arrays ajax codeigniter

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Country State City Dropdown list in PHP MySQL PHP

Country state city dropdown using ajax in php. You'll learn how to populate country city state dropdown based on previous selection in php using ajax

Cannot send array to php via AJAX?

Well I followed&nbsp;<a href="https://stackoverflow.com/questions/9001526/send-array-with-ajax-to-php-script" target="_blank">this</a>&nbsp;question, but cannot send array to php it returns me always empty:

Ajax Live Data Search using jQuery PHP MySQL

ajax php live search with mysql database example. Here you will learn how to implement ajax live data search using php mysql database with example

Hire PHP Developer

Looking to develop a PHP based website from scratch or revamp your existing website? **[HourlyDeveloper.io](https://hourlydeveloper.io/ "HourlyDeveloper.io")** has always been an industry leader for companies and business owners looking to hire...

Hire CodeIgniter Developer

Want to create unique, scalable web and app solutions? At **[HourlyDeveloper.io](https://hourlydeveloper.io/ "HourlyDeveloper.io")**, Expert CodeIgniter developer works particularly for you and your project. You can **[Hire CodeIgniter...