3 Replies Latest reply on Apr 23, 2006 4:48 PM by resonant

    stucture vs array

    susanring


      hello
      i am still a bit confused from the 2
      stucture vs array

      how are these used for maybe reporting system.
      like
      display a query results to a page.
        • 1. Re: stucture vs array
          Dan Bracuk Level 5
          I consider a structure to be like a big box into which you can put variables. Then, if you send the structure somewhere, to a cfc for example, all the variables go with it.

          I consider an array to a way of arranging data.

          To display query results on a page, for the most part, forget arrays and structures. All they do is complicate things.

          However, if you want to be confused even more than you are now, a query can be viewed as a structure containing a bunch of one dimensional arrays. The arrays are your columns, not your rows. The usefulness of this is that you can use array functions, such as arraysum(), on your query.

          Didn't clear things up a bit, did it.
          • 2. Re: stucture vs array
            BSterner Level 1
            An array is an ordered set who's indices are whole numbers. Members are referenced by a particular number.

            a[1] = "John";
            a[2] = "Mary";
            a[3] = "Tom";

            The order of an array is important.

            A structure (analogous to a hash map, associative array) is a data structure who's keys or "indices" can be alpha-numeric values. The members are referenced by these values.

            s["name1"] = "John";
            s["name2"] = "Mary";
            s["name3"] = "Tom";

            One notable difference betwen the 2 In coldfusion, is that arrays are passed by value, and structs by reference.
            • 3. Re: stucture vs array
              resonant
              Another thing to remember when comparing the two is that ColdFusion provides a lot more searching functionality for lists and structures that it does for arrays. There are uses for both and sometimes a use for a combination. Right now I am using a security scheme that parses and array of structures. It works very nicely.

              - JS