Re: [CDBI] Refresh variables for Object?

Perrin Harkins <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.class-dbi
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.