[CDBI] Using a TEMP column with has_a?

Jason Bodnar jason at shakabuku.org
Fri Jun 23 23:36:39 BST 2006

On Fri, 23 Jun 2006 15:31:22 -0700, Bill Moseley wrote
> On Fri, Jun 23, 2006 at 05:13:02PM -0500, Jason Bodnar wrote:
> > Currently, we have a class called PersonItem. It has two foreign keys --
> > person_id and item_id that reference the person table and the item table. I
> > wanted to make calls to $person_item->person_id() and $person_item->item_id()
> > return Person and Item objects, respectively. I know I can do this with
> > has_a() but that would break existing code that relies upon those methods
> > returning an integer (the IDs).
> How do you use that code such that it needs to be the value (integer)
> instead of the object? 

That's the problem. I'm not sure how it's used. It's a lot of code (five
developers over a year and a half) and it would take less time for me to write
the methods for person() and item() than to check all that code. Of course,
I'd prefer to do it the most CDBI-way. 

I didn't know that objects would stringify to the primary key (though I should
have suspected it). Thanks for the tip.


Jason Bodnar
jason at shakabuku.org

UnWired Buyer. The best way to win on eBay. Period.

More information about the ClassDBI mailing list