I use objectRecord.exists() after loading the record, I believe it just looks at the primary key to make sure that record is in the database and doesn’t care whether the record isDirty() or not.

 

Cheers, Chris

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Dave Shuck
Sent: 10 August 2006 20:01
To: [email protected]
Subject: Re: [Reactor for CF] Record object Question...?

 

LOL  on re-read or your message, I guess you and I are both right! :)

On 8/10/06, Dave Shuck <[EMAIL PROTECTED]> wrote:

Aaron I think that might be backwards, but to be honest I have to try it every time.

I *think* (NOT object.isDirty()) means it did load, but try it yourself and it won't take long to figure out!


~Dave

 

On 8/10/06, Aaron Lynch <[EMAIL PROTECTED] > wrote:

SAL VALVERDE wrote:
> any docs on the isDirty() method?
> or explaination...?
>
> sal
>
> Dave Shuck wrote:
>> Rather than checking lengths or types of data, we use the isDirty()
>> method.
>>
>> ~Dave
>>
>> On 8/10/06, *Doug Sims* < [EMAIL PROTECTED]
>> <mailto: [EMAIL PROTECTED]>> wrote:
>>
>>     Just curious and wanted feedback/drawbacks from the group on this
>>     approach:
>>     <cfif User.getUserId()>
>>     rather than this:
>>     <cfif len(User.getUserId()) and User.getUserId()>
>>
>>
>>
>>     Thanks,
>>     Doug S.
>>     www.evenamonkey.com <http://www.evenamonkey.com>
>>
>>
>>
>>     On 8/10/06, SAL VALVERDE < [EMAIL PROTECTED]
>>     <mailto:[EMAIL PROTECTED]>> wrote:
>>     >
>>     >  hey thanks Jared...
>>     >  and for the quick response too...
>>     >
>>     >
>>     >  sal
>>     >
>>     >
>>     >
>>     >  Jared Rypka-Hauer wrote:
>>     >  <cfif len(obj.getUserId ())> is usually how people do it,
>>     > but that can be frustrating if it returns 0, which means it
>>     > hasn't been loaded too.
>>     >
>>     > <cfif len(User.getUserId ()) and User.getUserId()> will
>>     > cover you if your userId is 0 (which means nothing's been
>>     > loaded because 0 isn't a valid pkey value in most cases).
>>     >
>>     > Laterz,
>>     > J
>>     >
>>     > On Thu, 10 Aug 2006 11:24:15 -0600
>>     >  SAL VALVERDE < [EMAIL PROTECTED]
>>     <mailto: [EMAIL PROTECTED]>> wrote:
>>     >
>>     >
>>     >  Hello all,
>>     > I have a quick simple question that I hope someone can
>>     > enlighten me with...
>>     > What would be best practice to see if a record object has
>>     > been loaded or not? my current script is as follows:
>>     >
>>     > <cfif len(userRecord)>
>>     >  <cfset
>>     > arguments.event.setValue("badLogin","Invalid Username
>>     > or Password") />
>>     >  <cfset
>>     > arguments.event.addResult("notLoggedIn") />
>>     >  <cfelse>
>>     >  <cfset session.isLoggedIn = true />
>>     >  <cfset session.username =
>>     > #userRecord.getuserName()# />
>>     >  <cfset arguments.event.addResult("loggedIn")
>>     > />
>>     >  </cfif>
>>     >
>>     > "userRecord" being the object...
>>     >
>>     >
>>     > I'm getting the following error:
>>     >
>>     > Complex object types cannot be converted to simple
>>     > values.
>>     > *Detail* The _expression_ has requested a variable or an
>>     > intermediate _expression_ result as a simple value,
>>     > however, the result cannot be converted to a simple
>>     > value. Simple values are strings, numbers, boolean
>>     > values, and date/time values. Queries, arrays, and COM
>>     > objects are examples of complex values.
>>     >
>>     > The most likely cause of the error is that you are trying
>>     > to use a complex value as a simple one. For example, you
>>     > might be trying to use a query variable in a <CFIF> tag.
>>     > This was possible in ColdFusion 2.0 but creates an error
>>     > in later versions.
>>     >
>>     >
>>     > thanks in advance...
>>     > sal
>>     >
>>     >
>>     > -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
>>     > -- -- -- -- -- -- -- --
>>     > 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] <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/
>>     < http://www.mail-archive.com/reactor%40doughughes.net/>
>>     -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
>>     -- -- -- -- --
>>
>>
>>
>>
>> --
>> ~Dave Shuck
>> [EMAIL PROTECTED] <mailto: [EMAIL PROTECTED]>
>> www.daveshuck.com <http://www.daveshuck.com>
>> www.worldwildweb.biz <http://www.worldwildweb.biz >
>> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
>> -- -- -- --
>> 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/
> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> -- -- -- --

The way I understand it is, you can do something like...

//try to load a user
User.load(UserId = something);

if (User.isDirty()){
    //you have a new User record on your hands
}
else {
    //User is NOT isDirty() so you have an existing User on your hands
}

Aaron


-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Reactor for ColdFusion Mailing List
[email protected]
Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --




--
~Dave Shuck
[EMAIL PROTECTED]




--
~Dave Shuck
[EMAIL PROTECTED]
www.daveshuck.com
www.worldwildweb.biz
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
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/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

Reply via email to