Jose,

I placed all three queries into one function and wrapped transaction
tags around the queries. Here is the guts of my function (except for
the arguments):

<!--- Insert record into product table --->
                                <cfquery name="rsInsertProduct" 
datasource="#application.dsn#">
                                        INSERT INTO products(
                                                prodTitle,
                                                prodModel,
                                                prodPic,
                                                prodSDesc,
                                                prodLDesc,
                                                prodHits,
                                                prodActive)
                                        VALUES(
                                                '#arguments.prodTitle#',
                                                '#arguments.prodModel#',
                                                '#arguments.prodPic#',
                                                '#arguments.prodSDesc#',
                                                '#arguments.prodLDesc#',
                                                '#arguments.prodHits#',
                                                #arguments.prodActive#)
                                </cfquery>
                                
                                <!--- Get prodID from the previously inserted 
record --->
                                <cfquery name="rsNewProduct" 
datasource="#application.dsn#">
                                        SELECT MAX(prodID) as new_prodID
                                        FROM products
                                        WHERE prodTitle = 
'#arguments.prodTitle#'
                                </cfquery>
                                
                                <!--- loop through the list of formats and 
insert a record for
each into the proddetails linking table --->
                                <cfloop collection="" list="#formats#" 
index="i" delimiters=",">
                                        <cfquery name="rsProdDetails" 
datasource="#application.dsn#">
                                                INSERT INTO prodDetails(
                                                        prod_ID,
                                                        prodformat_ID,
                                                        proddetailDesc,
                                                        proddetailPrice,
                                                        proddetailSpecial,
                                                        proddetailSpecialPrice,
                                                        proddetailDateAdded)
                                                VALUES(
                                                        
#rsNewProduct.new_prodID#,
                                                        #format_ID#,
                                                        
'#arguments.detailDesc#',
                                                        
'#arguments.detailPrice#',
                                                        
#arguments.detailSpecial#,
                                                        
'#arguments.detailSpecialPrice#',
                                                        
'#arguments.detailDateAdded#')
                                                </cfquery>
                                        </cfloop>

The last query is incomplete because it does not insert multiple
records. I am still working on this part, but before I finalized it I
decided to work on the form that would be passing the arguments the
values for this insert.

-Aaron

On 2/6/06, j s <[EMAIL PROTECTED]> wrote:
> Aaron,
>
> Can you post how you where able to do the inserts?  My situation is a little 
> tricky.
> My insert consist adding the form values to two tables. The values productID 
> and qty are added using using a function addProduct.  The options are added 
> using a second function called addOption.  I must first get the primary key 
> using transaction tag them pass that key to the second function along with 
> all the form.options.
>
> What I'm not clear on is:
>
> - if from the form page I send all the formfields to the first function 
> (addProduct)
>   how do i pass along all the form.option#count# values to the second
>   function(addOptions)?
>
> My guess is I should create either a list or an array for all the 
> form.options, pass it along the cart.cfc, get the primary key from the 
> addProduct function, some how use the list/array to insert using the 
> addOption fuction.
>
> Can anyone confirm this and point me to how do this?
>
> Form (fields):
> FORM.ProductID,
> FORM.Qty
> FORM.Option1 (option#count#)
>
> Tables:
> 1- cartTable - productLineID, productID, qty
> 2- optionIDTable - optionLineID, productLineIDoptionID
>
> Functions:
> cart.addProduct
> cart.addOption
>
> Thanks
>
> >Thanks Will,
> >
> >After getting the multiple values inserted I was going to work on
> >getting the multiple values updated as well. I have a CommunityMX
> >tutorial (http://www.communitymx.com/abstract.cfm?cid=E68A448AE1116988)
> >in my possession about updating multiple records that I was going to
> >use to implement my update CFC. However, I was needing something that
> >would tell me how to get the values from the same form field just as
> >with the insert.
> >
> >I will definitely take a look at your example! I am kind of surprised
> >that this seems to be more complicated then I thought. Perhaps because
> >linking tables is so common in db design that I thought these kinds of
> >inserts and updates would be basic.
> >
> >-Aaron
> >
> >On 2/4/06, Will Tomlinson <[EMAIL PROTECTED]> wrote:
> >>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:231495
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to