[Solar-talk] new model: has_one through

Rodrigo Moraes rodrigo.moraes at gmail.com
Wed May 2 07:08:40 PDT 2007


Hi,
I tried several set up combinations, and in the end I couldn't find a
way to access directly a related row (fecthOne()) mapped through an
intermediate table. There's an easy workaround - add a method or
extend __get() to retrieve it. Maybe I'm missing something obvious.

I would like, for example, to fetch a row $page and then access
$page->layout directly, mapped through Layout2Page. I have several
table schemas that works like this - one-to-one mapped trough a third
table:

Table Page
-------------------------
id
spec

Table Layout
-------------------------
id
spec

Table Layout2Page
-------------------------
id
page_id
layout_id

page_id's are unique in Layout2Page, but layout_id 's are not. How
should we name this? 'one-to-one with a map' or, hmm, maybe
'a-very-bad-schema'? :)

If you know some nice sites about database patterns, let me know!

cheers,
rodrigo


More information about the solar-talk mailing list