Tom,

The exists method is used in cases where the object uses a non identity
field as its PK.  With an integer identity as the PK, the value for that
field is only set when the record is committed.  If it's 0 then you know
that it's new and needs to be inserted.  If it's 1 or more then you know it
exists and needs to be saved.

Many people use UUIDs as PK values.  In many cases (especially in database
where you can't have an expression be a default value) people will set the
default value in the TO. IE: 

<cfset this.fooId = createuuid() />

When a new record is created it'll have an ID, but you won't be able to tell
from that if it really is a new record or an existing record.  That's why
for those I add the call to the exists method.  

I don't want to add exists in all cases because I don't think that you
should have that extra call to the DB unless it's really needed.

Doug


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Tom Chiverton
Sent: Wednesday, May 31, 2006 8:04 AM
To: [email protected]
Subject: Re: [Reactor For CF] Why no exists() method for objects with
auto_increment PK ?

On Wednesday 31 May 2006 12:37, Doug Hughes wrote:
> This is how I plan to keep it for release.

That's cool, nice to know we're fixing things - so it must be close :-)
Having talked about things here, I have a better idea of how things work in 
Reactor.

Any comment on why DAO's based on tables with an auto_inc primary key don't 
have an exists() method and/or exposing the DAO exists() method via the 
Record ?

-- 
Tom Chiverton

****************************************************

This email is sent for and on behalf of Halliwells LLP.

Halliwells LLP is a limited liability partnership registered in England and
Wales under registered number OC307980 whose registered office address is at
St James's Court Brown Street Manchester M2 2JF.  A list of members is
available for inspection at the registered office. Any reference to a
partner in relation to Halliwells LLP means a member of Halliwells LLP.
Regulated by the Law Society.

CONFIDENTIALITY

This email is intended only for the use of the addressee named above and may
be confidential or legally privileged.  If you are not the addressee you
must not read it and must not use any information contained in nor copy it
nor inform any person other than Halliwells LLP or the addressee of its
existence or contents.  If you have received this email in error please
delete it and notify Halliwells LLP IT Department on 0870 365 8008.

For more information about Halliwells LLP visit www.halliwells.com.

We are pleased to announce that Halliwells LLP has been voted AIM Lawyer of
the Year at the 2005 Growth Company Awards



 

-- 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