Re: Cross between MightHave and HasMany?
[prev]
[thread]
[next]
[Date index for 2004/11/05]
On Fri, 5 Nov 2004 09:21:45 -0500, William McKee <william@xxxxxxx.xxx>
wrote:
> On Tue, Nov 02, 2004 at 02:06:45PM -0800, Peter Speltz wrote:
>> But if you want , Have you tried making a Temp column of person
>> category? I
>> haven't tried Temp but from reading the docs, i hope to be able to say:
>>
>> Person->columns( Temp => [ "category"]);
>> Person->has_a(category => "PersonCategory");
>>
>> .... then have everything work just like if the category column was in
>> the
>> person table. It should be able to update the PersonCategory object.
Oops, oversaw this suggestion. I've not tried it, but it sounds like I'd
get the PersonCategory object, and not the Category object, when getting
that. It would be nice if has_a worked 'via' another table too, like
has_many does.
> Wouldn't using might_have provide the same results with less code?
>
> e.g.
>
> Person->might_have(category => "PersonCategory" => qw/cat_id/);
>
> This brings up the question of whether CDBI makes category into a Temp
> column. Tony?
This presumably has the same drawback as the suggestion above. If I have
to fetch the PC object, and from that get the Category object, I might as
well go write the SQL..
>
>> .... then have everything work just like if the category column was in
>> the
>> person table. It should be able to update the PersonCategory object.
>>
>> prsn_obj->category->cat_id($cgi_val);
>> prsn_obj->update; # or maybe prsn_obj->category->update;
>
> I would think that the prsn_obj->category->update would be the correct
> call. Personally, I wouldn't use this setup with a M2M relation. To get
> a category name, you'd need to use something like:
>
> prsn_obj->category->category;
>
> Or stringify Category to the category column (which potentially
> introduces other weirdness).
>
Yup, isnt it all fun. Would be nice if there was a clear cut way to do
one-to-one relationships. I'd write a new C::B::Relationship class if I
could make any sense of them.
Jess
--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
|
(message missing)
|