Re: Array argument array return
I'm using Flash remoting and I've only been able to use very simple CF code in
the past. Now I need to pass my function an array as an argument and them
search the database and return the query a nested array.
I have a database that I need to pass an array of numbers which are ids (these
are ids of sales people) in the database. For each one I need to check a column
for a number and all the numbers for this id up. So each sold contract has its
own line in the database. The sales person's id is a column in the database.
I'm just counting the number of contract this person has made. I can do this
one by one and then add in flash but it's not very efficent.
So my resulting array returned should be something like this: (sales person
id, number of contracts)
array item  = 17 - sales id
array item  = 4 - contracts sold
array item  = 29 - sales id
array item  = 2 - contracts sold
Can anyone point me in the direction of how I would set this up in CF?
arrayItems = arrayNew(2);
arrayItems = 17;
arrayItems = 4;
arrayItems = 29;
arrayItems = 2;
Of course you would probably do this with some kind of loop over the
record set return from you database query.
I would also tend to use a structure (associative array) as I find them
arrayItems = arrayNew(1);
arrayItems = structNew(); //technically not required but good form.
arrayItems["salesID"] = 17;
arrayItems["contracts"] = 4;
arrayItems = structNew();
arrayItems["salesID"] = 29;
arrayItems["contracts"] = 2;
Note: that ColdFusion arrays do not start with an index of 0, they start