Re: [CDBI] Does Class::DBI require hash-based objects?

[prev] [thread] [next] [Date index for 2006/01/03]

From: Steven Mackenzie
Subject: Re: [CDBI] Does Class::DBI require hash-based objects?
Date: 19:12 on 03 Jan 2006

Jesse Sookne wrote:

>
> Does Class::DBI require that its subclasses (application base classes
> as described in the Class::DBI doc) use hash-based objects?
>
I've been adding attributes to Class::DBI objects using the "inside out"
classes/hashes described in Perl Best Practices. I haven't seen any
conflict with the hash based attributes used in the CDBI part of the
hierarchy, though I don't actually use Class::Std, just the technique
described in that book.

Also, I think that Class::DBI uses closures internally, though I'm not
sure what for (I'm only really interested in the API, and new to Perl).
I don't think that will conflict with add new attributes via the
Class::Std mechanisms either.

A part of the API that did cause me confusion though was that I found
objects being DESTROYed before I expected them to be. I had assumed, for
example, that if I accessed rows in a child table via an accessor in the
parent (via a has_many relation) that the children would stay referenced
while I maintained the reference to the parent table. I don't know why I
assumed that, and it is wrong.

As long as I maintain my own references to objects, my attributes remain
with the object.

However, a further wrinkle, which you will find in the list archives, is
that in certain scenarios Class::DBI will return more than one object to
represent the same row in the database. Look in the archives for "Bug
with sequences and the object cache".


_______________________________________________
ClassDBI mailing list
ClassDBI@xxxxx.xxxxxxxxxxxxxxxx.xxx
http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi

Re: [CDBI] Does Class::DBI require hash-based objects?
Steven Mackenzie 19:12 on 03 Jan 2006

Re: [CDBI] Does Class::DBI require hash-based objects?
Steven Mackenzie 20:23 on 03 Jan 2006

Re: [CDBI] Does Class::DBI require hash-based objects?
Steven Mackenzie 16:09 on 05 Jan 2006

Generated at 01:21 on 10 Jan 2006 by mariachi v0.52