Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

createData in cfloop array question?

Participant ,
Apr 13, 2009 Apr 13, 2009

I have an array with shop items, the cfdump is:

-------

1

AMOUNT  1
ID      8FD457C0-2399-11DE-98AA000C7674A083

2

AMOUNT  1
ID      6A1B47A0-1895-11DE-A201000C7674A083

-------

Then i want to loop the array and perform a createData (writes new record to database) action, when i
have one item in the array it works, when i have 2 items in the array
it doesn't work.

I thought it must be because somehow the createData creates a sort of
duplicate record error, but then again, i use the to address only
the current array loop item.

I don't see it anymore, anyone had a fresh insight?

<cfset sailsobj = createObject
('component',application.stcoapi.shopproductbehaviour_sails.packagepath) /


<cfloop index="i" from="1" to="#arraylen(session.shopcart)#">

<!--- set product sails --->
<cfset sailsprops.productobjectid = session.shopcart.id>
<cfset sailsprops.productamount = session.shopcart.amount>
<cfset sailsobj.createData(stProperties=sailsprops)>

</cfloop

475
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 13, 2009 Apr 13, 2009

When in doubt, look at your data.  Inside your loop, either output or dump session.shopcart.id and session.shopcart.amout.  Do you see what you expect to see?

What might be relevent is that you don't really have an array as much as you have a bunch of structures.  That might be messing you up.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 14, 2009 Apr 14, 2009

The data was correct, i had an answer on:http://groups.google.com/group/farcry-dev/browse_thread/thread/36734838ec832aa8.

So the problem was that i wasn't initializing the properties for each loop, therefore were using values from the previous loop for all next loops, that gave an error in the createdata (write record to database) function, i think a duplicate record error a like thing.

Thanks!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 14, 2009 Apr 14, 2009
LATEST

So the problem was that i wasn't initializing the properties for each loop, therefore were using values from the previous loop for all next loops, that gave an error in the createdata (write record to database) function, i think a duplicate record error a like thing.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources