Google

Kategorie

Reprezentacja Wiedzy

Kalendarz

August 2007
M T W T F S S
« Jul   Sep »
 12345
6789101112
13141516171819
20212223242526
2728293031  

CakePHP 1.2 : zapisywanie modeli

August 23rd, 2007 by prond

Domyś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 »