Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function datatab($action='read'){
- if (IS_AJAX) {
- $action = $this->request->post('action');
- switch ($action){
- default:
- $this->read();
- break;
- case 'read':
- $this->read();
- break;
- case 'create':
- $this->create($this->request->post('data'));
- break;
- case 'edit':
- $this->update($this->request->post('id'));
- break;
- case 'remove':
- $this->delete($this->request->post('data'));
- break;
- }
- }
- }
- private function create($values){
- $data = $this->rest->getRequest();
- $data['requestMethod'] = $this->rest->requestMethod;
- $this->pb->create($values);
- $this->outputJSON($data, 200);
- }
- private function read(){
- $data = $this->rest->getRequest();
- $data['requestMethod'] = $this->rest->requestMethod;
- $data['aaData'] = $this->pb->read();
- $this->outputJSON($data, 200);
- }
- private function update($id){
- $data = $this->rest->getRequest();
- $data['requestMethod'] = $this->rest->requestMethod;
- $values= $this->request->post('data');
- $where = array('id'=> $this->request->post('id',FILTER_SANITIZE_NUMBER_INT));
- $this->pb->update($values,$where);
- $this->outputJSON($data, 200);
- }
- private function delete($where){
- $data = $this->rest->getRequest();
- $data['requestMethod'] = $this->rest->requestMethod;
- $this->pb->delete($where);
- $this->outputJSON($data, 200);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement