Tuesday, January 12, 2010

Associations to other models

Hello,

I have a model called sites. A Site hasAndBelongToMany Entries. An
Entry belongsTo one Type and one Saving.

So, I have an entries_sites table, and an entry has a type_id and a
saving_id

I want to fetch all Entries that belong to a Site, and also get the
associated Type and Saving for each Entry. The problem is, if I fetch
a Site it will fetch all associated Entries along with it, but won't
also fetch the Type and Saving associated with each entry. If I fetch
Entries I can't query them based on site_id (as far as I know) because
that field isn't in the table, it's in the entries_sites table.

Is there a way to fetch a Site and get all associated Entries and the
associated Type and Saving for each Entry? Thanks in advance!

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate