Re: [CDBI] Best way to tell if two objects are the same?
[prev]
[thread]
[next]
[Date index for 2006/01/11]
On Wed, Jan 11, 2006 at 09:42:59AM -0500, Michael Peters wrote:
> > I need to know if $obj1 eq $obj2, and I'm wondering the best way. I
> > suppose ref($obj1) eq ref($obj2) would fail without Live_Object index.
>
> You mean if they are the same object or refer to the same row in the database.
> If object, then simply comparing the address given by Scalar::Util::refaddr
> would be enough.
That relies on Live_Object index being in use (to see if they point to
the same row), IIUC.
> If you want to check if they are the same row in the db, then you could compare
> their table() and id() to see if they are the same.
>
> Is that what you were asking for?
I just thought that it might be a common operation. I kind of
expected for there to be a CDBI method available, then I saw that code
that generates the unique key for %Live_Object is inlined.
Might be a nice use for '==' overload.
--
Bill Moseley
moseley@xxxx.xxx
_______________________________________________
ClassDBI mailing list
ClassDBI@xxxxx.xxxxxxxxxxxxxxxx.xxx
http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi