Re: Let me adjust my question (was: A strange problem I have...)

[prev] [thread] [next] [Date index for 2004/12/13]

From: Perrin Harkins
Subject: Re: Let me adjust my question (was: A strange problem I have...)
Date: 16:23 on 13 Dec 2004
On Mon, 2004-12-13 at 14:43 +0200, karjala_lists@xxxxxxx.xxx wrote:
> Question: How do I make object $a up to date with the database, and not 
> return the 'old' balance when I do $a->balance ?

Get rid of the object (set it to undef) and fetch it again.

> > $user1 = User->retrieve(a);
> > $user2 = User->retrieve(b);
> > ...other code...
> > $user1->balance($user1->balance - $amount);
> > $user2->balance($user2->balance + $amount);
> >
> > However when the two users are the same user, and the desired result 
> > would be for the user's balance to remain unchanged, what happens is 
> > that the balance decreases by $amount.

This should work fine under Class::DBI 0.96, if your Perl supports weak
references.  Otherwise, those objects will be totally separate and will
not know they are really the same object.

- Perrin

(message missing)

Re: Let me adjust my question (was: A strange problem I have...)
Perrin Harkins 16:23 on 13 Dec 2004

Generated at 09:04 on 20 Dec 2004 by mariachi v0.52