> I do a load(ID=0) which is supposed to load a new record, but the previous
> record is loaded, even though ID is set to 0.
Incorrect, load(ID=0) does not load a new record, it TRIES to load a
record with ID=0 but as no record exists it will fail. load(ID=0) is
the shorthand for setID(0) and then load().
Heres an example of whats going on, modify it to fit your app and take a look
<cfset user = reactor.createRecord("User")>
<cfset user.load(id=2)>
<cfdump var="#user.isDirty()#">
<cfdump var="#user._getTo()#">
<cfset user.load(id=0)>
<cfdump var="#user.isDirty()#">
<cfdump var="#user._getTo()#">
Notice that after the second load call isDirty() will return true
because load failed and the data in the record is now dirty.
Its not safe to reuse a single instance of a Record in your
application. You should create a new Record object and then call load
on it each time. DAO, Gateways and Validators are safe to be cached
for reuse.
Cheers, Chris
On Feb 18, 2008 6:51 AM, Byron Raines <[EMAIL PROTECTED]> wrote:
> Sorry, misunderstood. There is no record with ID=0 after the save. The
> ID is auto-increment, so there should never be a record with ID=0. The
> problem I'm running into is that whenever I am loading an existing
> record, the next time time I load a blank record, int this case I'm
> using ID=0 since I do not have any records with ID=0, the values from
> the last loaded existing record are loaded (ie firstname, lastname, etc).
>
> Let me add that if I do: event=participant.edit&ID=0&init=true
> I blank record is loaded (I assume since I an reloading the app).
>
> Hope I'm explaining this clearly.
> Byron
>
> Brian Kotek wrote:
> > What I'm saying is that after you do this:
> >
> > 1.) Load a record (ID=5).
> > 2.) Make changes and save.
> > 3.) Redirected to the main listing page.
> >
> > Stop and go look at the database and confirm that there is no record
> > with an ID of 0 in there, because if there is, and you do load(ID=0)
> > you'll get that record.
> >
> > On Feb 17, 2008 10:21 PM, Byron Raines <[EMAIL PROTECTED]
> > <mailto:[EMAIL PROTECTED]>> wrote:
> >
> > Brian,
> > ID is the primary key and auto-increment. If I load (ID=5), it
> > saves as 5. If I load with (ID=0), if remembers the previous loaded
> > record, then saves with a new ID. I don't see how reactor is
> > remembering a record that was loaded from 2 requests prior.
> >
> > 1.) Load a record (ID=5).
> > 2.) Make changes and save.
> > 3.) Redirected to the main listing page.
> > 4.) Then create a blank record (ID=0). The record from (ID=5) is
> > loaded. However, getID() is equal to 0.
> > 5.) Save that record and a new record with new ID is saved.
> >
> > Byron
> >
> > Brian Kotek wrote:
> > > If you look at the database, are you sure that the record you load
> > > with an ID of 5 is being saved with an ID of 5, and not an ID of 0?
> > >
> > > On Feb 16, 2008 9:23 PM, Byron Raines <[EMAIL PROTECTED]
> > <mailto:[EMAIL PROTECTED]>
>
> > > <mailto:[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>> wrote:
> > >
> > > Hi. I have a problem I just cannot figure out.
> > >
> > > I have a situation where I am loading an existing record,
> > editing,
> > > then
> > > saving it. Then I load a new empty record. However, the values
> > > of the
> > > previously loaded record are appearing on my form page. I
> > cannot
> > > figure
> > > out if I'm actually not loading a new record, or if its
> > caching the
> > > previous record. Example: if do a load(ID=5), edit it,
> > save it.
> > > The I
> > > do a load(ID=0) which is supposed to load a new record, but the
> > > previous
> > > record is loaded, even though ID is set to 0.
> > >
> > > This is part of a Model-Glue 2.0 app. I posted this on the
> > model-glue
> > > google group included code samples etc. While there were
> > alot of good
> > > suggestions, I was not able to find anything that helped.
> > If anyone
> > > would not mind taking a look at the thread and offer
> > suggestions, I'd
> > > appreciate it.
> > >
> > > This on is stumping me.
> > >
> > >
> >
> > http://groups.google.com/group/model-glue/browse_thread/thread/3bcdc568347ce277
> > >
> > > Byron
> > >
> > >
> > > -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> > -- --
> > > -- -- -- -- --
> > > Reactor for ColdFusion Mailing List
> > > [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
> > <mailto:[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>
>
> > > Archives at:
> > http://www.mail-archive.com/reactor%40doughughes.net/
> > > -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> > -- --
> > > -- -- -- -- --
> > >
> > >
> > >
> > > -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> > > -- -- -- --
> > > Reactor for ColdFusion Mailing List
> > > [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
> > > Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
> > > -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> > > -- -- -- --
> >
> >
> > -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> > -- -- -- -- --
> > Reactor for ColdFusion Mailing List
> > [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
> > Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
> > -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> > -- -- -- -- --
> >
> >
> >
> > -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> > -- -- -- --
> > Reactor for ColdFusion Mailing List
> > [EMAIL PROTECTED]
> > Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
> > -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> > -- -- -- --
>
>
> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> --
> Reactor for ColdFusion Mailing List
> [EMAIL PROTECTED]
> Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> --
>
>
>
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Reactor for ColdFusion Mailing List
[EMAIL PROTECTED]
Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --