Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
smokin_joe #1
"Updating" a Session Variable Row
In its original application, the following "borrowed" code enables data to be
written to a session variable.
I would like to change this so that, a previously established variable, can at
this time be Updated with the current contents.. That is, initially I set the
session variable to capture the Customer ID. In another screen, I want to add
additional data to the original variable. So, I would like to check to see if
the CustomerID is present and if there are NO products already there I want to
UPDATE that row with the new information.
Then, if the CustomerID and same ProductID are there, I want to update that.
I hope that I am making sense.... what this code is currently doing is ADDing
a new row and not updating the appropriate one.
Can anyone offer any advice?
<!--- Update shopping cart --->
<cfelseif attributes.action is "update">
<!--- Loop through basket and remove selected items --->
<cfset newBasket = queryNew("CustomerID, ProductID, ProductName, Quantity,
saleDate")>
<cfloop query="session.basket">
<!--- Add anything that isn't in the delete list --->
<cfif not listFind(attributes.productID, productID)>
<cfset tempValue = queryAddRow(newBasket)>
<cfset tempValue = querySetCell(newBasket, "saleDate", saleDate)>
<cfset tempValue = querySetCell(newBasket, "CustomerID", CustomerID)>
<cfset tempValue = querySetCell(newBasket, "ProductID", ProductID)>
<cfset tempValue = querySetCell(newBasket, "ProductName", ProductName)>
<cfset tempValue = querySetCell(newBasket, "Quantity", quantity)>
</cfif>
</cfloop>
<!--- set the basket to the new values --->
<cfset session.basket = newBasket>
<!--- Add product to query --->
<cfelseif attributes.action is "add">
<!--- check to see if the product is in the baset already --->
<cfset productRow = listFind(valueList(session.basket.productID),
attributes.productID)>
<!--- Product is in basket, update quantity --->
<cfif productRow neq 0>
<!--- determine the new quantity and the correct row --->
<cfset oldQuantity = listGetAt(valueList(session.basket.quantity), productRow)>
<cfset newQuantity = attributes.quantity + oldQuantity>
<cfset tempValue = querySetCell(session.basket, "Quantity", newQuantity,
productRow)>
<!--- Product is not in basket, add it --->
<cfelse>
<cfset tempValue = queryAddRow(session.basket)>
<cfset tempValue = querySetCell(session.basket, "saleDate", "#Now()#")>
<!---<cfset tempValue = querySetCell(session.basket, "saleDate", "#Now()#")>
--->
<cfset tempValue = querySetCell(session.basket, "CustomerID",
attributes.CustomerID)>
<cfset tempValue = querySetCell(session.basket, "ProductID",
attributes.ProductID)>
<cfset tempValue = querySetCell(session.basket, "ProductName",
attributes.ProductName)>
<cfset tempValue = querySetCell(session.basket, "Quantity",
attributes.quantity)>
</cfif></cfif>
smokin_joe Guest
-
Automatic "updating adobe online components" on launch
My gets stuck during launch while in the process of adding the awedbfiles4.awe. -
STOPPING the "Adobe Updating" Component thing...NIGHTMARE
How do I turn off the automatic online "reporting" thing that happens everytime I launch GoLive 6.0 and Photoshop 7.0 -- I have to wait while it... -
How can I "know" the difference between a session timed out and a session that did session.abort?
Any clues? Thanks for your time. Adam -
#25366 [NEW]: form buttons of type "image" dont send "submit" $_POST variable in IE
From: jordanolsommer at imap dot cc Operating system: Windows XP PHP version: 4.3.2 PHP Bug Type: Variables related Bug... -
Which is faster? Dim dv As New DataView(session("myDataTable")) or CType(session("myDataTable"))
Hello, let's say my session("myDataTable") is type of DataTable Now what is faster? a) Dim dv As New DataView(session("myDataTable")) b) Dim...



Reply With Quote

