O'Reilly logo

CakePHP 2 Application Cookbook by Jorge González, James Watts

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Injecting data

Sometimes you need to save initial data for your newly created tables or ensure that old data is consistent with one of your migrations right after you applied it.

The CakeDC Migrations plugin provides a way to alter your database contents while running a migration, so you can execute custom logic before or after a given migration. This custom code can be used to insert or update data in your database to keep your changes consistent.

Getting ready

In this recipe, we'll add a new feature to our blog which involves setting up a unique group for our profiles. We'll want to allow groups to be dynamic, so a new groups table and Group model will be created and associated with our Profile model.

We'll first create a table for our groups using ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required