Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Felix Geisendorfer's Blog:
Modeling relationships in CakePHP (faking Rails’ ThroughAssociation)
Oct 26, 2006 @ 12:12:52

On the ThinkingPHP Blog today, Felix brings another feature of the popular Rails framework over to the world of PHP - in CakePHP specifically:

The idea behind it is pretty simple: Often you have two Models that are associated with each other where setting the associations themself via hasAndBelongsToMany isn't quite enough for what you try to to.

He gives an example of the code, a method to get around the typical CRUD pattern without breaking it. His example involves users and groups and storing information surrounding them. Storing the data about the groups and which users belong to which groups is easy - it's when you start including some meta-data into the mix that things get a little complex.

He provides the sample code to make it all work - three models and three controllers - and the database structure to work behind the scenes.

tagged: cakephp framework rails throughassociation hasandbelongstomany association cakephp framework rails throughassociation hasandbelongstomany association

Link:

Felix Geisendorfer's Blog:
Modeling relationships in CakePHP (faking Rails’ ThroughAssociation)
Oct 26, 2006 @ 12:12:52

On the ThinkingPHP Blog today, Felix brings another feature of the popular Rails framework over to the world of PHP - in CakePHP specifically:

The idea behind it is pretty simple: Often you have two Models that are associated with each other where setting the associations themself via hasAndBelongsToMany isn't quite enough for what you try to to.

He gives an example of the code, a method to get around the typical CRUD pattern without breaking it. His example involves users and groups and storing information surrounding them. Storing the data about the groups and which users belong to which groups is easy - it's when you start including some meta-data into the mix that things get a little complex.

He provides the sample code to make it all work - three models and three controllers - and the database structure to work behind the scenes.

tagged: cakephp framework rails throughassociation hasandbelongstomany association cakephp framework rails throughassociation hasandbelongstomany association

Link:


Trending Topics: