Re: [CDBI] Having a column named 'id' as part of a multi-column primary key
[prev]
[thread]
[next]
[Date index for 2005/08/11]
Randal L. Schwartz wrote:
> Scotty> Is there any reason the above code shouldn't read:
>
> Yes. What happens when I call $row->id? What do I get? Just
> the individual column, or the entire multicolumn ID?
>
> ->id is reserved for a reason!
Ah, ok I missed the subtlety here, which is that when you have a single
primary key which is named "id", the result of calling id() the column
accessor is the same as calling id() the generic Class::DBI method.
I thought instead, the implication was, "well, if id is really your
primary key, then it's more important to have that be a column accessor
than an object identifier". I looked a bit more at the cdbi code
though, and it looks like id() is used for all sorts of things
internally, so that's out. I do wish it was named something a bit more
obscure and less likely to collide with column names though:)
However, this all raises a separate question: what do you do when you're
retrofitting cdbi on top of an existing schema, that may have namespace
collisions between columns and cdbi reserved names? Is there a way to
remap a column to a different accessor name? Or another trick I don't
know of?
Thanks,
Scotty
_______________________________________________
ClassDBI mailing list
ClassDBI@xxxxx.xxxxxxxxxxxxxxxx.xxx
http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi