public function get_items_that_do_not_exist_post() { $item_ids = $this->input->post('itemIds'); // [1, 2, 3, 4, 5] $items_repo = new Items_Repository($this->base_model->get_db_instance()); $data = array(); foreach ($item_ids as $item_id) { if (!$items_repo->item_exists($item_id)) { array_push($data, $item_id); } } echo json_encode($data); // outputs the id of the items that does not exist }
public function item_exists_post() { $items_repo = new Items_Repository($this->base_model->get_db_instance()); echo $items_repo->item_exists($this->input->post('itemId')); }