Tag Archives: Models

CakePHP – Models Part 2

Callback Methods

If you want to sneak in some logic just before or after a CakePHP model operation, use model callbacks. These functions can be defined in model classes (including your AppModel) class. Be sure to note the expected return values for each of these special functions.

Read more

CakePHP – Models Part 1

Naming

  • Ingredient
  • extends AppModel
  • ingredient.php

The Model is automatically available to the Controller when the name matches

function index() {
//grab all ingredients and pass it to the view:
$ingredients = $this->Ingredient->find(‘all’);
$this->set(‘ingredients’, $ingredients);
}


Read more