if you need any help, just drop me a line and I'll try to get back to
you asap.
Cheers,
Gian.
On 26 Mar, 21:44, Johnny Ferguson <hyperfle...@gmail.com> wrote:
> It's a little difficult to wrap my head around, but I think I see
> what's going on.
>
> belongsTo is a many to one relation, so many PracticeInstance belong
> to 1 PracticeItem
>
> That defies my intuition, because it's more natural for me to think of
> a PracticeItem as belonging to a PracticeSession. The PracticeSession
> has a PracticeItem.
>
> I'll work through developing this app, and see if my understanding
> doesn't grow a little. Thanks, Gian.
>
> On Mar 26, 3:17 pm, Gianluca <gc1...@googlemail.com> wrote:
>
>
>
> > Hello Johnny,
>
> > class PracticeItem extends AppModel {
>
> > }
>
> > class PracticeInstance extends AppModel {
> > var $belongsTo = 'PracticeItem';
>
> > }
>
> > class PracticeSession extends AppModel {
> > var $hasMany = 'PracticeInstance';
>
> > }
>
> > tblPracticeInstances
> > * id
> > * practiceitem_id
> > * practicesession_id
> > * ....
>
> > tblPracticeSessions
> > * id
> > * ....
>
> > Let me know if you need more.
>
> > Cheers,
> > Gian.
>
> > On 26 Mar, 18:57, Johnny Ferguson <hyperfle...@gmail.com> wrote:
>
> > > Looking here:http://book.cakephp.org/view/78/Associations-Linking-Models-Together
>
> > > I'm certain my issue is due to a personal lack of understanding.
>
> > > I'm trying to homebrew a simple app to keep track of my guitar
> > > practice.
>
> > > I have the following models:
> > > PracticeItem: a specific exercise to be practiced any number of times
> > > PracticeInstance: an instance of having practiced one specific
> > > PracticeItem
> > > PracticeSession: a collection of PracticeInstance
>
> > > My immediate instinct is to say PracticeInstance "hasOne"
> > > PracticeItem.
>
> > > According to the Book: X hasOne Y => table Y having an X_id field.
>
> > > In my case PracticeInstance "hasOne" PracticeItem would mean:
> > > PracticeItems has a field practice_instance_id
>
> > > This makes no sense because if I were to create a PracticeItem called
> > > "Major Scales 2", I would plan to practice it multiple times.
>
> > > If the field for this PracticeItem looks like
> > > id = 123
> > > title = "Major Scales 2"
> > > practice_instance_id = 23
>
> > > then I would have to duplicate the PracticeItem every time I practiced
> > > it.
>
> > > To me it would make more sense if PracticeInstance looked like:
> > > id = primaryKey, autoincrement
> > > datetime = ...
> > > comment = ...
> > > timeSpent = ...
> > > practice_item_id = 123
>
> > > Can anyone explain where I might have mixed things up?
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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?hl=en
To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
No comments:
Post a Comment