Chapter 6. Complex Datatypes

Besides the simple datatypes covered in Chapter 2, ColdFusion supports several complex datatypes you can use to increase the complexity and functionality of your applications. These datatypes include lists, arrays, structures, query objects, and component objects. With the exception of component objects (these are covered later in Chapter 23), this chapter discusses each of these complex datatypes and provides numerous examples illustrating how they can further enhance your applications.

Lists

A list is a special type of string that contains delimited elements. For example, “a,b,c,d,e,f,g” is a list where “a”, “b”, “c”, “d”, “e”, “f”, and “g” are considered the list elements while the comma (,) is considered the delimiter. Lists are commonly used to store related items in a single variable. For example, you might use a list to store all the primary key values for a group of database records you want to delete.

It should be noted that ColdFusion treats list elements containing null values as though they don’t exist. For example, the list “1,2,,4” contains only three list elements (as far as ColdFusion is concerned) even though there is a null list element “,,”. The concept of a null list element shouldn’t be confused with a blank list element as in “1,2, ,4” which contains four list elements, the space occupying list element three being counted. To further illustrate the point, consider Example 6-1, which creates three lists using CFSET tags and then ...

Get Programming ColdFusion now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.