CakePHP 1.2 : zapisywanie modeli
August 23rd, 2007 by prondDomyślnie ‘wypieczony’ w Cake 1.2 kod zapisujący model wygląda następująco:
function add() { if (!empty($this->data)) { $this->cleanUpFields(); $this->Page->create(); if ($this->Page->save($this->data)) { $this->Session->setFlash('The Page has been saved'); $this->redirect(array('action'=>'index'), null, true); } else { $this->Session->setFlash('The Page could not be saved. Please, try again.'); } } }
Moim zdaniem brakuje w nim rozróżnienia sytuacji, w której pola są nie poprawne od błędu przy zapisie do bazy.
Read the rest of this entry »
Posted in CakePHP | No Comments »