[Solar-talk] new model: has_one through
Rodrigo Moraes
rodrigo.moraes at gmail.com
Sun Apr 29 12:44:22 PDT 2007
On 4/29/07, Paul M Jones wrote:
> It sounds like you want the following:
>
> 1. You want to say "foo" has one "bar" through "map", where "map"
> also has one "bar".
>
> 2. You want to let "foo" directly get its "bar".
Yes, exactly.
> I would say to set up a direct "foo has-one bar", and a corresponding
> "bar belongs-to foo". (Your foo can have one of as many other models
> it needs.) Map can still have one bar, too.
>
> Does that make sense at all? Is there something about the schema or
> requirement that I'm missing here?
Trying to understand what you mean...
Well, neither 'foo' or 'bar' have foreign columns to reference each
other. So I don't know how to set up "foo has-one bar" or "bar
belongs-to foo". I can, however, use $foo->map->bar, and this would be
ok, but I was wondering if it would be possible to make 'foo' access
'bar' directly.
Basically I have "pages", and each one has a "layout". The same layout
is used on several pages, but each page has only one layout. There are
no foreign keys; they are mapped by a third table, "layout2page".
- Model_Page: id, other_col
- Model_Layout: id, other_col
- Model_Layout2Page: page_id, layout_id
I'm a bit lost after several model setup tries; and in the end I'm
using $page->map->layout. :-|
After this I think I should compile some basic recipes for Solar_Sql_Model. :)
rodrigo
More information about the solar-talk
mailing list