Sorry, I'll repost this - my database is Bookingdate not Bookingnight Hi
Im having some trouble with a model association - yes, I have tried the manual! For each Booking I have, I can have many Bookingnights *Booking* Booking.id .... *Bookingdate* Bookingdate.id Bookingdate.booking_id In my Booking model, I am able to get all the associated Bookingdates without issue. var $hasMany = array( 'Bookingdate' => array( 'className' => 'Bookingdates', 'foreignKey' => 'booking_id', ) ); My problem is when I try and go back the other way. I have my Bookingdate.id, and want to get the associated booking. I would think that it should be belongsTo in my Bookingdate model? var $belongsTo = array( 'Booking' => array( 'className' => 'Bookings', 'foreignKey' => 'booking_id' ) ); ==> Doesnt Work Is there something obvious that I'm missing? On Wednesday, 27 June 2012 18:26:42 UTC+12, Sanfly wrote: > > Hi > > Im having some trouble with a model association - yes, I have tried the > manual! > > For each Booking I have, I can have many Bookingnights > > *Booking* > Booking.id > .... > > *Bookingnight* > Bookingnight.id > Bookingnight.booking_id > > In my Booking model, I am able to get all the associated Bookingnights > without issue. > > var $hasMany = array( > 'Bookingdate' => array( > 'className' => 'Bookingdates', > 'foreignKey' => 'booking_id', > > ) > > ); > > My problem is when I try and go back the other way. I have my > Bookingnight.id, and want to get the associated booking. > > I would think that it should be belongsTo? > > var $belongsTo = array( > 'Booking' => array( > 'className' => 'Bookings', > 'foreignKey' => 'booking_id' > ) > > ); > > ==> Doesnt Work > > Is there something obvious that I'm missing? > > Thanks! > > > > -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php