[CDBI] Refresh variables for Object?
Perrin Harkins
perrin at elem.com
Sat Dec 16 02:05:04 GMT 2006
Graham Melcher wrote:
> The reason for this that i'm iterating over the result of a rather large
> query, such that the results later in the iteration may no longer be up
> to date.
Be careful. You will have to deal with possibilities like the objects
being deleted since you ran your original query.
> I could rely on the columns not being essential, or
> re-retrieving the object (although I think that would simply result in
> accessing the same object in memory).
Even if you have the live objects index enabled, this will result in a
fresh fetch from the database:
my $artist = Artist->retrieve($id);
undef $artist;
$artist = Artist->retrieve($id); # back to the db
There is also a private method called _attribute_delete() which can
remove specific columns from an object so that they have to be re-fetched.
- Perrin
More information about the ClassDBI
mailing list