Skip to Main Content
Programming ColdFusion MX, 2nd Edition
book

Programming ColdFusion MX, 2nd Edition

by Rob Brooks-Bilson
August 2003
Intermediate to advanced content levelIntermediate to advanced
1140 pages
68h 45m
English
O'Reilly Media, Inc.
Content preview from Programming ColdFusion MX, 2nd Edition

Name

Duplicate

Synopsis

                  
                  Duplicate(variable)

Creates a duplicate copy of variable without any references to the original. variable can be any ColdFusion datatype with the exception of component objects (COM, CORBA, and Java). Duplicate( ) overcomes problems associated with copying structures and queries. Generally, when copying a structure or query, any future change to the original object results in a change to the copy. Duplicate( ) eliminates this by making an independent copy of the original object. The duplicate copy isn’t affected by changes to the original. The Duplicate( ) function is especially useful for copying nested structures and XML objects, and should be used in place of the StructCopy( ) function. The following example illustrates the difference between copying and duplicating query objects:

<!--- create a query object ---> <cfset Products = QueryNew("ProductName, Color")> <cfset NewRows = QueryAddRow(Products, 1)> <cfset QuerySetCell(Products, "ProductName", "Widget", 1)> <cfset QuerySetCell(Products, "Color", "Silver", 1)> <!--- create a copy and a duplicate of the query ---> <cfset CopyProducts = Products> <cfset DuplicateProducts = Duplicate(Products)> <cfoutput> <b>Original:</b> You selected a #Products.Color# #Products.ProductName#.<br> <cfset QuerySetCell(Products, "Color", "Black", 1)> <b>Copy:</b> You selected a #CopyProducts.Color# #CopyProducts.ProductName#.<br> <b>Duplicate:</b> You selected a #DuplicateProducts.Color# #DuplicateProducts.ProductName#. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Programming ColdFusion

Programming ColdFusion

Rob Brooks-Bilson

Publisher Resources

ISBN: 0596003803Supplemental ContentErrata Page