Introduction to Cold Fusion By Tom Dubeck Overview
Introduction to Cold. Fusion By Tom Dubeck
Overview n n n What is Cold. Fusion? How does it compare to other scripts? Some example code. Why you might want to use it. Installing Cold. Fusion. Controlling Cold. Fusion.
What is Cold. Fusion? n n Cold. Fusion != Cold Fusion, it will not power your computer or win you a Nobel Prize in Physics It will however, let you write powerful web applications relatively quick and straightforward as compared to some other web scripts.
Other language Comparisons Perl n n n Interpreted on a character basis Any shared data must go through hidden HTML field or manually created cookies. Both HTML and Headers must be spelt out using Print commands Syntax similar to C++ but with a lot more punctuation characters in weird places. Object Oriented?
Other Language Comparison ASP/VBscipt n n n Interpreted on a Character basis Pages are loaded individually, but can be easily connected through Session and Application variables. ASP code is inserted in between normal HTML with special <% %> tags (much like JSP). Very different Syntax than C/Perl/etc, but very human readable. Barely Object Oriented
Other Language Comparison Cold. Fusion n n Interpreted on a Tag basis. Also administered by local Admin page. Like ASP, has Session, Application, and other scopes that can share information from page to page. Each Logic control or Data structure is represented by its own HTML/XML-ish tag, highly intermingled. Structures and Custom tags, not quite objects
Source Comparison
Tag based Code n n n <cfset> to declare/set variables <cfloop> for any kind of loop, index/while/container <cfoutput> for both plain printing and containers/lists <cfquery> for database access <cfparam> for easy form field or argument validation and access
Operators n n n In CFML, <>= already used in tags. = - is, equal, or eq != - is not, not equal ne ><>=- gt, lt, greater than or equal, gte XOR, EQV, IMP, ^ and MOD supported as well.
Make your own tags, kind of like OOP n Define a template My. Class. cfm n n n Use <cfparam> to take in attributes Use thistag. executionmode to set behaviors for endtags Tag is called<cf_My. Class>.
Why Cold. Fusion? n n n Very high interactivity and support with Macromedia products include Flash and Dreamweaver. Verity Search Engine takes all the work out of full text searches. Admin page keeps important system settings (Databases, error handling) standardized between pages and hidden from those that don’t need to know. Very powerful query control Easy to use variable validation.
Cold. Fusion in Action Verity Search through Database n <cfquery name="descriptions" data. Source=“Store"> Select Item. Number, Description From Main. Inventory </cfquery> n <cfparam name=“txt" default=“nothing"> <cfindex collection="Product. Search" body="Description" key="Item. Number" query="descriptions"> n <cfsearch name="Products" collection="Product. Search" criteria="#txt#"> n n <cfquery name=“results" datasource=“Store" dbtype="ODBC"> Select * From Products Where key in (#Value. List(Products. Key)#) </cfquery>
Cold. Fusion in Action Query of Queries n n <cfquery name=“alldata" data. Source=“Store"> Select * From Main. Inventory </cfquery> <cfquery name=“Get. By. Type" dbtype=“query"> Select Item. Number, Description From alldata Where type=“Electronics” </cfquery>
Query of Queries n n n Uses the Query object instead of the database. Greate for narrowing results or reordering. Although it supports it, not a good idea to join.
In case you don’t like CFML n n <cfscript> tag- works like <script> tag for Java. Script or <%%> for *SP. Supports for, while, do while loops identical to Java. Script. Function to declare functions, var to declare varibles, return anything you want. In other words, just like Java. Script. No print command, have to return a string and <cfoutput>
Installing Cold. Fusion n Can be done with or without a previous Web server. Can get a free developer’s version to tinker with on your machine from www. macromedia. com. Default settings generally work.
Cold. Fusion Admin n Conveniant place to control your Data Sources, Verity Collections, System settings, and Debug/Error handling.
Cold. Fusion Resources n n n Macromedia’s Developers’ Forum Various online tutorials Various books
- Slides: 18