Ciao Langdon,

> > In a "traditional" way, I would create a N-N relationships, with an
> > intermediate table that contains a worker_id, a site_id, a date and
> > the number of hours. In fact, I already created this table, adding the
> > mandatory "id" field that Cake wants, but I can't translate it to a
> > Model.
>
> I would set it up this way:
>
> Three models:
>
> - worker
> - presence
> - site
>
> worker -> hasMany -> presence
>
> presence -> belongsTo -> site
> presence -> belongsTo -> worker
>
> site -> hasMany -> presence
>
> It sounds like you already have the foreign keys worked out.
>
> This should cover your needs.  Now you can create a "presence" instance
> and assign a site and a worker to it.  Presences can be looked up by
> site, or worker, or site, or worker can be looked up by presence.

Thanks a lot, I'll go implement my models using your suggestion!
In fact, this blog post also suggests to do as you told me:

http://www.thinkingphp.org/2006/10/26/modeling-relationships-in-cakephp-faking-rails-throughassociation/

.. but being new at CakePHP I thought to model it as an HABTM
relationship.
So please correct me: I shouldn't use a HABTM relationship because in
that way
I couldn't set up other attributes for the relationship itself (the
presence),
right?

Thanks again!
Regards,

--
[ Andrea Spadaccini - a.k.a. lupino3 - GLUGCT - from Catania - ICQ :
91528290 ]
[ GPG ID: 5D41ABF0 - key on keyservers - Debian GNU / Linux - Kernel
2.6.18.4 ]
[ Linux Registered User 313388 -
a(dot)spadaccini(at)catania(dot)linux(dot)it ]
[                 Error, no keyboard -- press F1 to
continue.                 ]


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to