Taylor Otwell Thu Jan 06 08:58:02 -0500 2011

Subject: Help with Associations

For example, let's say I have a "Document" table, a "Chapters" table, and an "Articles" table.

Each Document has many Chapters, and each Chapter has many Articles. But, there are also multiple documents on the documents table.

So, on Articles table, I would need Document ID AND Chapter ID. How would I define the association on the Chapters model to connect to the Articles on Document ID AND Chapter ID? Would I have to connect it on the Document ID and then each time I do a Find add a condition to tie in the Chapter ID, or is there a way to define it totally on the model without having to use conditions on my Find?


Jacques Fuentes Thu Jan 06 21:40:18 -0500 2011

It seems like what you're asking for is composite keys which PHP-AR does not support. Unfortunately, you would need to add conditions to issue your find. Composite keys is something I'd like to eventually support, but it's going to take quite a bit of effort.