Will,
Any reason you can't use createUUID() to generate the unique
identifier for each cart/shopper and then timestamp their entry into
the database so that you can clean them out later beyond a certain date?
Then you won't have to worry about them being duplicated.
Jon
On Nov 29, 2006, at 9:08 AM, Will Tomlinson wrote:
> Just noticed a flaw in my store app. I'm generating what I THOUGHT
> were unique ID's for carts and shoppers. They get plugged into the
> db for later use.
>
> There seem to be a few records with the same ID. This ID field
> isn't the PK of the table.
>
> When the app starts, a shopper service and cart service are
> initialized. This is where I'm creating the ID. I WAS using
> randrange() and the date appended to it. Just changed that to
> timeformat() to get an exact time and maybe help this problem out.
>
> What's odd is I'm lookin in the cart table, and I see no such
> duplication. All the ID's are unique, yet I'm using the same method
> to generate THOSE too.
>
> Here's where it's created. Any ideas?
>
> <cfset APPLICATION.cartservice = CreateObject("component",
> "cfcs.cartservice").init(dsn=application.settings.dsn)>
> <cfset APPLICATION.shopperservice = CreateObject("component",
> "cfcs.shopperservice").init(browser=CGI.http_user_agent)>
>
>
> <cffunction name="init" access="public" output="false"
> returntype="shopperservice">
> <cfargument name="browser" required="yes">
> <cfset VARIABLES.shopperStats = StructNew()>
> <!--- Create a shopper ID for this shopper --->
> <cfset VARIABLES.shopperStats.shopperID = TimeFormat(Now(),
> "hmmss") & DateFormat(Now(),"m-dd-yy")>
> <!--- Setup other variables that come in from onAppStart in
> App.cfc --->
> <cfset VARIABLES.shopperStats.shopperBrowser = ARGUMENTS.browser>
> <cfreturn this>
> </cffunction>
>
> And here's for the cartID. No problem I see with these ID's.
>
> <cffunction name="init" access="public" output="false"
> returntype="cartservice">
> <cfargument name="dsn">
> <cfset VARIABLES.dsn = ARGUMENTS.dsn>
> <cfset VARIABLES.finalCartTotal = 0>
> <!--- Create a cart ID for this cart --->
> <cfset VARIABLES.cartID = TimeFormat(Now(), "hmmss") & DateFormat
> (Now(),"m-dd-yy")>
> <cfset VARIABLES.totals = StructNew()>
> <cfset VARIABLES.cartItemsAdded = false>
>
> <cfreturn this>
> </cffunction>
>
> Thanks,
> Will
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four
times a year.
http://www.fusionauthority.com/quarterly
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:262024
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4