Wednesday, January 18, 2012

Re: Trouble Linking Models

You set those associations up in their respective models. So, for example, in your Record model, Record hasOne Image. You can then do a find from the Band model that will bring in Records and Images. I'd recommend looking up the Containable behaviour as that will make finds really easy.

Jeremy Burns
Class Outfit

http://www.classoutfit.com

On 18 Jan 2012, at 11:54:46, Clint wrote:

I'm trying to link a few models together, but I'm having difficulty in linking the second level of model in.

For example, say I have a Band which has many Members, many Gigs and many Records. This can be easily represented in the Band model as:

var $hasMany = array('Members', 'Gigs', 'Records');

Everything links fine given the correct field names, but then how do I link another model to Members, Gigs, or Records? Say each Record has one cover Image.. I'm not sure how to define / represent it.

Thanks!

Clint

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: