[CDBI] Best way to tell if two objects are the same?

Michael Peters mpeters at plusthree.com
Wed Jan 11 14:42:59 GMT 2006



Bill Moseley 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.

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?

-- 
Michael Peters
Developer
Plus Three, LP





More information about the ClassDBI mailing list