createData in cfloop array question?

0 views
Skip to first unread message

Marco van den Oever

unread,
Apr 13, 2009, 8:41:36 PM4/13/09
to farcry-dev
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 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 [i] 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[i].id>
<cfset sailsprops.productamount = session.shopcart[i].amount>
<cfset sailsobj.createData(stProperties=sailsprops)>

</cfloop>

Blair McKenzie

unread,
Apr 13, 2009, 10:34:58 PM4/13/09
to farcr...@googlegroups.com
Try initialising sailsprops:
<cfset sailsprops = structnew() />
before setting the properties and saving.

createData is probably adding properties that you need to clear out.

Blair

Marco van den Oever

unread,
Apr 14, 2009, 8:08:34 AM4/14/09
to farcry-dev
YES! So because I'm setting these properties in a loop that handles
different array items i need to initialize those properties each time
so that the property values for the current item are used and not the
property values set in the previous loop...

Thanks.

On Apr 14, 4:34 am, Blair McKenzie <shi...@gmail.com> wrote:
> Try initialising sailsprops:
> <cfset sailsprops = structnew() />
> before setting the properties and saving.
>
> createData is probably adding properties that you need to clear out.
>
> Blair
>
> On Tue, Apr 14, 2009 at 10:41 AM, Marco van den Oever <
>
Reply all
Reply to author
Forward
0 new messages