Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class PracticeSessionsController extends AppController {
- var $components = array('Autocomplete');
- var $uses = array('PracticeItem');
- function index(){
- $this->set('data', $this->PracticeSession->find('all'));
- }
- function add(){
- if(!empty($this->data)){
- die(debug($this->data));
- if($this->PracticeSession->save($this->data)) {
- $this->Session->setFlash("Your practice session was saved successfully");
- $this->redirect(array('action' => 'index'));
- }
- }
- }
- function delete($id) {
- // ensure the record exists, set a flash if not
- if (!$this->PracticeSession->exists()) {
- $this->Session->setFlash('Practice Session id=' . $id . " does not exist");
- $this->redirect(array('action' => 'index'));
- }
- $this->PracticeSession->delete($id);
- $this->Session->setFlash("Practice Session id=" . $id . " has been deleted");
- $this->redirect(array('action' => 'index'));
- }
- function edit($id) {
- // ensure the record exists, set a flash if not
- if (!$this->PracticeSession->exists()) {
- $this->Session->setFlash('Practice Session id=' . $id . " does not exist");
- $this->redirect(array('action' => 'index'));
- }
- $this->PracticeSession->id = $id;
- if (empty($this->data)){
- $this->data = $this->PracticeSession->read();
- }
- else {
- if ($this->PracticeSession->save($this->data)) {
- $this->Session->setFlash('Practice Session id=' . $id . " has been successfully updated");
- $this->redirect(array('action' => 'index'));
- }
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement