[Solar-talk] new model: has_one through
Paul M Jones
pmjones at ciaweb.net
Sun Apr 29 08:34:50 PDT 2007
On Apr 29, 2007, at 10:11 AM, Rodrigo Moraes wrote:
> Hi,
> This is related to the new Model class. I have a model with related
> data accessed through a foreign table for one-to-one relationships. I
> first tried to setup a 'has_one-through' relationship, but then I
> realized that it was not possible (currently only 'has_many-through'
> is possible). I'm wondering if 'has_one-through' makes sense or if I
> am missing something.
I'm not sure has-one-through makes sense to me. Has-many-through is
a way to implement many-to-many, not one-to-one.
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".
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?
--
Paul M. Jones <http://paul-m-jones.com>
Solar: Simple Object Library and Application Repository
for PHP5. <http://solarphp.com>
Join the Solar community wiki! <http://solarphp.org>
Savant: The simple, elegant, and powerful solution for
templates in PHP. <http://phpsavant.com>
More information about the solar-talk
mailing list