Table Of Content4124FM.qxd 8/21/02 7:18 AM Page iii
Mastering™
ColdFusion® MX
Arman Danesh
Raymond Camden
Selene Bainum
Guy Rish
San Francisco London
4124FM.qxd 8/21/02 7:18 AM Page ii
4124FM.qxd 8/21/02 7:18 AM Page i
Praise for Mastering ColdFusion 5
“I’ve only been programming ColdFusion 6 months, thanks to your book, I’ve managed to
implement an extensive application for my employer—The British Army. Many thanks.”
—Sybex reader, Calvin Syres
“I was very new in CF but after reading this book in a few weeks I became expert of CF. I
designed large database web site using this book, understanding both the programming language
and concept behind each syntax.”
—Sybex reader, Iqbal Balushi
“As a beginner this book taught me the essentials of what I needed to know to start creating
ColdFusion code almost on the first page. I created the templates they described and this gave me
the hunger to read the inevitable ‘lets sit down for the boring bit’chat. Totally changed my company’s
intranet and created good database driven pages which made addition and deletion of data easier.
Everything I needed was contained in this book and now have the confidence I needed with Cold-
Fusion code. The reference area at the back makes you keep the book at hand with both CF and SQL
help included.”
—P. Szelesi, courtesy of Amazon.com
4124FM.qxd 8/21/02 7:18 AM Page ii
4124FM.qxd 8/21/02 7:18 AM Page iii
Mastering™
ColdFusion® MX
Arman Danesh
Raymond Camden
Selene Bainum
Guy Rish
San Francisco London
4124FM.qxd 8/21/02 7:18 AM Page iv
Associate Publisher: Richard Mills
Acquisitions and Developmental Editor: Tom Cirtin
Editor: Rebecca Rider
Production Editor: Liz Burke
Technical Editors: Raymond Camden, Guy Rish
Book Designer: Maureen Forys, Happenstance Type-O-Rama
Electronic Publishing Specialists: Jill Niles, Judy Fung
Proofreaders: Dave Nash, Monique van den Berg, Nancy Riddiough, Yariv Rabinovitch, Lori Newman, Laurie O’Connell, Emily Hsuan
Indexer: Ted Laux
Cover Designer: Design Site
Cover Illustrator: Tania Kac, Design Site
Copyright © 2002 SYBEX Inc., 1151 Marina Village Parkway, Alameda, CA 94501. World rights reserved. No part ofthis publication may be
stored in a retrieval system, transmitted, or reproduced in any way, including but not limited to photocopy, photograph, magnetic, or other record,
without the prior agreement and written permission ofthe publisher.
Library ofCongress Card Number: 2002108073
ISBN: 0-7821-4124-2
SYBEX and the SYBEX logo are either registered trademarks or trademarks ofSYBEX Inc. in the United States and/or other countries.
Screen reproductions produced with FullShot 99. FullShot 99 © 1991-1999 Inbit Incorporated. All rights reserved.
FullShot is a trademark ofInbit Incorporated.
Internet screen shot(s) using Microsoft Internet Explorer 5.0 reprinted by permission from Microsoft Corporation.
TRADEMARKS: SYBEX has attempted throughout this book to distinguish proprietary trademarks from descriptive terms by following the
capitalization style used by the manufacturer.
The author and publisher have made their best efforts to prepare this book, and the content is based upon final release software whenever possible.
Portions ofthe manuscript may be based upon pre-release versions supplied by software manufacturer(s). The author and the publisher make no
representation or warranties ofany kind with regard to the completeness or accuracy ofthe contents herein and accept no liability ofany kind
including but not limited to performance, merchantability, fitness for any particular purpose, or any losses or damages ofany kind caused or
alleged to be caused directly or indirectly from this book.
Manufactured in the United States ofAmerica
10 9 8 7 6 5 4 3 2 1
4124FM.qxd 8/21/02 7:18 AM Page v
To Mrs. G: thanks for all those samosas…
—Arman Danesh
For Jeanne, Jacob, and Jacqueline.
—Raymond Camden
For Dave.
—Selene Bainum
To Amber.
—Guy Rish
4124FM.qxd 8/21/02 7:18 AM Page vi
Acknowledgments
Even though the task
of writing such long treatises now seems almost routine, it can never
mask the enormous contributions of so many people in bringing projects such as these to reality.
First, I must thank the entire team brought together to make this book a reality. Notably, I am
grateful to my coauthors, Selene Bainum, Raymond Camden, and Guy Rish; our team of project
managers and editors at Sybex including Richard Mills, Tom Cirtin, Liz Burke, and Rebecca Rider;
and the many others who helped in the task of producing this book.
Finally, my wife, Tahirih, and son Ethan, deserve credit for tolerating the long hours I spent in
front of the computer screen throughout the writing of this book.
—Arman Danesh
I’d like to begin by thanking my wife, Jeanne. You have no idea how much your support means to
me. I wouldn’t be able to do things like this without your constant support and encouragement.
Again, thank you!
I want to thank the staff at Sybex for letting me participate in this project. Specifically, I’d like to
thank Tom Cirtin, Richard Mills, Liz Burke, and Rebecca Rider. Your hard work made my job a heck
of a lot easier. Next, I’d like to thank my co-authors: Arman Danesh, Guy Rish, and Selene Bainum.
It was great working with you and I’m looking forward to the next edition!
—Raymond Camden
I would first like to thank Kristin Motlagh—I would not have been a part of this project if not
for her efforts and encouragement. I am also very grateful to the entire staff at Sybex—particularly
Tom Cirtin, Liz Burke, Peter Gaughan, and Rebecca Rider. Their leadership and editing helped
develop this book into what it is today.
I would also like to thank my fellow authors, Arman, Guy, and Raymond. It was a great experience
working with all of you. Special thanks to Raymond for his superb job as technical editor and for
teaching me more things than I care to admit.
Finally, much thanks and love to my husband, Dave, for supporting this project even though it
meant not seeing me for hours on end while I sat in front of my computer. I could not have done it
without you.
—Selene Bainum
First and foremost I want to thank my dear wife, Amber. She suffers with me the long hours it
takes to write this and other texts. She is, in a moment and without effort, all the best that I could
ever hope to be.
I would like to thank my coauthors, Selene Bainum, Raymond Camden, and Arman Danesh.
Also, I would very much like to thank everyone at Sybex: Tom Cirtin, Richard Mills, Liz Burke, Peter
Gaughan, and Rebecca Rider (who is absolutely incredible). It is astonishing the myriad of people
necessary to publish a technical book and how much everyone has to actively contribute to produce a
finished work. To everyone whose name does not appear or should have had theirs in a larger font—
thank you! Also, not to be forgotten, thanks to Kristin Motlagh, whom I missed on this edition.
—Guy Rish
4124FM.qxd 8/21/02 7:18 AM Page vii
About the Authors
AArrmmaann DDaanneesshhis pursuing an advanced degree in computer science at Simon Fraser University in
Vancouver. He also serves as the technical manager for The Bahá’í World (http://www.bahai.org),
the official website of the Bahá’í International Community, and Bahá’í World News Service (http://
www.bahaiworldnews.org), a ColdFusion-driven online news service. Additionally, he is the editorial
director for Juxta Publishing Limited (http://www.juxta.com) and manages the ColdFusion-based
websites of Landegg International University, a private, international University in Switzerland. He
has been working with ColdFusion since 1997 and maintains many other ColdFusion-based websites.
Arman has written more than a dozen books, including SAIR Linux & GNU Certified Administrator
All-in-One Exam Guide (Osborne-McGraw Hill, 2001), Safe and Secure: Secure Your Home
Network and Protect Your Privacy Online(Sams, 2001),and Teach Yourself JavaScript in a Week
(Sams, 1996).
RRaayymmoonndd CCaammddeennis a software engineer for Macromedia, Inc. A long time ColdFusion user,
Raymond is a former member ofTeam Macromedia and a contributing author to the Mastering
ColdFusionseries published by Sybex Inc. He also presents at numerous conferences and contributes
to online webzines and the ColdFusion Developer’s Journal. He and Rob Brooks-Bilson created and
run the Common Function Library Project (http://www.cflib.org), an open source repository of
ColdFusion UDFs. He also formed and helps manage the Hampton Roads ColdFusion User Group
(http://www.hrcfug.org).
SSeelleennee BBaaiinnuummhas been working with ColdFusion since version 1.5 back in 1996, and with both
SQL Server and Oracle for over five years. She has created several dynamic web-based applications
for many notable clients including the National Institutes of Health, Citibank, General Electric, and
Schlumberger Limited. Selene has spoken at several ColdFusion conferences and seminars across the
country, and is a coauthor of the ColdFusion MX Developer’s Handbook (Sybex, 2003). She created
and maintains WebTricks (http://www.webtricks.com), a well-known tutorial site for ColdFusion,
SQL, and JavaScript developers. Since 1998, she has been a member ofTeam Allaire/Team Macromedia,
providing assistance to hundreds of developers on Macromedia’s ColdFusion support forums. Selene is
also the cofounder and Chief Software Architect of Limited Reality (http://www.limitedreality.com),
a software development firm specializing in applications for mobile devices and web platforms.
GGuuyy RRiisshh is a freelance software developer. He holds instructor certificates from Macromedia and
Rational Software and has taught in San Francisco State University’s Multimedia Studies program.
Most recently, he has been the technical editor or coauthor for various web tools books such as the
Mastering ColdFusionseries (Sybex), Dreamweaver MX/Fireworks MX Savvy(Sybex, 2002), Inside
Flash MX(New Riders, 2002). He also authors the recurrent article series in the ColdFusion
Developer’s Journal, “Cold Cup O’Joe.”Guy has spoken numerous times at various conferences and
user groups (in and out of the US) about the intersection of OO and web technologies and practices.