$this->load->model('User_Model'); $user_data = array( 'name' => 'John', 'age' => 25, 'email' => 'john@example.com' ); $this->User_Model->update($user_data, 1);
$this->load->model('Post_Model'); $post_data = array( 'title' => 'New title', 'content' => 'New content' ); $where = array('id' => 2, 'user_id' => 1); $this->Post_Model->update($post_data, $where);In this example, we are updating the post data for the post with ID 2 and belonging to the user with ID 1. We pass the data to be updated as well as a where condition in the form of an array to the update method. The library used for these examples is MY_Model, which is a PHP library designed to simplify working with databases and performing common CRUD operations.