Created
April 19, 2019 05:31
-
-
Save harendra21/b5a7176f88801ee2b425d18baff27d0f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class TaskCtrl extends CI_Controller { | |
public function add_update_task() | |
{ | |
$json = file_get_contents('php://input'); | |
$data = json_decode($json, TRUE); | |
$id = $data['id']; | |
$title = $data['title']; | |
$status = $data['status']; | |
$description = $data['description']; | |
$data_array = array( | |
'title' => $title, | |
'status' => $status, | |
'description' => $description | |
); | |
if(empty($id)){ | |
$this->db->insert('task',$data_array); | |
}else{ | |
$this->db->where('id',$id); | |
$this->db->update('task',$data_array); | |
} | |
echo '1'; | |
} | |
public function get_task(){ | |
$data = $this->db->where('status !=' , 'delete')->order_by('id','DESC')->get('task'); | |
if($data->num_rows() > 0){ | |
print_r(json_encode($data->result_array())); | |
} | |
} | |
public function action_task(){ | |
$json = file_get_contents('php://input'); | |
$data = json_decode($json, TRUE); | |
$id = $data['formData']['id']; | |
$data_array = array( | |
'title' => $data['formData']['title'], | |
'status' => $data['action'], | |
'description' => $data['formData']['description'] | |
); | |
$this->db->where('id',$id); | |
$this->db->update('task',$data_array); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment