db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dan Allen <...@mojavelinux.com>
Subject updating a record
Date Fri, 07 Mar 2003 11:24:42 GMT
Say I have a profile form on my site.  The user fills in the updated
information and then I use the setXXX methods in the Model class, in
this case User, to update the information.  However, in order for it
to update and not add a new record, I need to have an instance of
the record which I am working with from the relation table.

So....my question is, is it always necessary to retrieve a record
before doing save() in order to make it update a record which
already exists?  If so, would I do something like:

 User user = UserPeer.findByUsername("sampleUsername");
 if (user == null)
 {
     user = new User();
 }

 user.setPassword("foobar");
 user.save();

Does that look about right?

Dan

-- 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
Daniel Allen, <dan@mojavelinux.com>
http://www.mojavelinux.com/
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
'One Microsoft Way' is more than just an address.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

Mime
View raw message