SHARE
TWEET

Untitled

a guest May 19th, 2017 44 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.     class PracticeSessionsController extends AppController {
  3.         var $components = array('Autocomplete');
  4.         var $uses = array('PracticeItem');
  5.        
  6.         function index(){
  7.             $this->set('data', $this->PracticeSession->find('all'));
  8.         }
  9.        
  10.         function add(){
  11.             if(!empty($this->data)){
  12.                 die(debug($this->data));
  13.                 if($this->PracticeSession->save($this->data)) {
  14.                     $this->Session->setFlash("Your practice session was saved successfully");
  15.                     $this->redirect(array('action' => 'index'));
  16.                 }
  17.             }
  18.         }
  19.        
  20.         function delete($id) {
  21.             // ensure the record exists, set a flash if not
  22.             if (!$this->PracticeSession->exists()) {
  23.                 $this->Session->setFlash('Practice Session id=' . $id . " does not exist");
  24.                 $this->redirect(array('action' => 'index'));
  25.             }
  26.            
  27.             $this->PracticeSession->delete($id);
  28.             $this->Session->setFlash("Practice Session id=" . $id . " has been deleted");
  29.             $this->redirect(array('action' => 'index'));
  30.         }
  31.        
  32.         function edit($id) {
  33.             // ensure the record exists, set a flash if not
  34.             if (!$this->PracticeSession->exists()) {
  35.                 $this->Session->setFlash('Practice Session id=' . $id . " does not exist");
  36.                 $this->redirect(array('action' => 'index'));
  37.             }
  38.            
  39.             $this->PracticeSession->id = $id;
  40.             if (empty($this->data)){
  41.                 $this->data = $this->PracticeSession->read();
  42.             }
  43.             else {
  44.                 if ($this->PracticeSession->save($this->data)) {
  45.                     $this->Session->setFlash('Practice Session id=' . $id . " has been successfully updated");
  46.                     $this->redirect(array('action' => 'index'));
  47.                 }
  48.             }
  49.         }
  50.     }
  51. ?>
RAW Paste Data
Top