[CDBI] Re: Refresh variables for Object?
"Edward J. Sabol" <sabol-2oVx0MVsMgiP/[email protected]>
| Newsgroups | gmane.comp.lang.perl.modules.class-dbi |
|---|---|
| Message-ID | <[email protected]> |
Graham Melcher wrote: > I'd like to clear the 'essential' and any other cache'd values for an > object such that they must be re-queried from the database when > accessed. I've looked over the cpan docs and the wiki, but I can't find > that sort of function. If I needed to do that, I guess I would do something like the following: $artist->remove_from_object_index(); $artist->discard_changes() unless $artist->autoupdate; $artist = Music::Artist->retrieve($artist->id); Obviously, you can skip the discard_changes() if you know you definitely haven't made any changes to the object or if you are using autoupdate mode. It's only real purpose is to avoid the warning message you get when an altered, uncommitted CDBI object is DESTROY'ed. It should be simple enough to devise a generic "refresh" method which does the above steps (and handles MCPKs!) that you can put in your CDBI base class. If you do come up with a generic method like that, please add it to the wiki! Hope this helps, Ed