Query Objects

Query objects are special ColdFusion data structures that hold record sets. Query objects are similar in structure to two-dimensional arrays and are made up of rows and columns (like a spreadsheet). There are three ways to create a query object:

  • Using the cfquery or cfstoredproc tag to retrieve a record set from a data source. We haven’t covered the cfstoredproc tag yet; we’ll get to it in Chapter 11. For now, just be aware that the tag can return a record set just like the cfquery tag.

  • Certain CFML tags such as cfftp and cfhttp return information stored in a query object.

  • Query objects can be manually created using QueryNew( ) and other associated query manipulation functions.

By this point, you should be quite familiar with the first method, in which query objects are automatically returned by the cfquery tag. The second method has to do with certain CFML tags returning information stored as query objects. These tags are covered in detail later in the book. We’re going to focus on the third method in this section, creating and manipulating query objects using QueryNew( ) and several other CFML functions. Creating a query in this way is useful when you want to make application-generated data available as a query object. This technique is especially useful when used within custom tags and components to return a query result set. Custom tags are covered in Chapter 21, components in Chapter 22. The query manipulation functions can also add additional data to an ...

Get Programming ColdFusion MX, 2nd Edition 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.