180 likes | 350 Views
Introduction to ColdFusion. By Tom Dubeck. Overview. What is ColdFusion? How does it compare to other scripts? Some example code. Why you might want to use it. Installing ColdFusion. Controlling ColdFusion. What is ColdFusion?.
E N D
Introduction to ColdFusion By Tom Dubeck
Overview • What is ColdFusion? • How does it compare to other scripts? • Some example code. • Why you might want to use it. • Installing ColdFusion. • Controlling ColdFusion.
What is ColdFusion? • ColdFusion != 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 • 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 ComparisonASP/VBscipt • 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 ComparisonColdFusion • 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
Tag based Code • <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 • 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 • Define a template MyClass.cfm • Use <cfparam> to take in attributes • Use thistag.executionmode to set behaviors for endtags • Tag is called<cf_MyClass>.
Why ColdFusion? • 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.
ColdFusion in ActionVerity Search through Database • <cfquery name="descriptions" dataSource=“Store"> Select ItemNumber, Description From MainInventory </cfquery> • <cfparam name=“txt" default=“nothing"> • <cfindex collection="ProductSearch" body="Description" key="ItemNumber" query="descriptions"> • <cfsearch name="Products" collection="ProductSearch" criteria="#txt#"> • <cfquery name=“results" datasource=“Store" dbtype="ODBC"> Select * From Products Where key in (#ValueList(Products.Key)#) </cfquery>
ColdFusion in ActionQuery of Queries • <cfquery name=“alldata" dataSource=“Store"> Select * From MainInventory </cfquery> • <cfquery name=“GetByType" dbtype=“query"> Select ItemNumber, Description From alldata Where type=“Electronics” </cfquery>
Query of Queries • Uses the Query object instead of the database. • Greate for narrowing results or re-ordering. • Although it supports it, not a good idea to join.
In case you don’t like CFML • <cfscript> tag- works like <script> tag for JavaScript or <%%> for *SP. • Supports for, while, do while loops identical to JavaScript. • Function to declare functions, var to declare varibles, return anything you want. In other words, just like JavaScript. • No print command, have to return a string and <cfoutput>
Installing ColdFusion • 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.
ColdFusion Admin • Conveniant place to control your Data Sources, Verity Collections, System settings, and Debug/Error handling.
ColdFusion Resources • Macromedia’s Developers’ Forum • Various online tutorials • Various books