Last active
September 27, 2019 01:30
-
-
Save nastanford/9237173 to your computer and use it in GitHub Desktop.
Beginner ColdFusion – ColdFusion Art Gallery ORM No Framework Lesson 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfcomponent displayname="CFArtGallery" output="true" hint="Handle the application."> | |
<!--- Set up the application. ---> | |
<cfset THIS.Name = "CFArtGallery" /> | |
<cfset THIS.ApplicationTimeout = CreateTimeSpan( 0, 0, 1, 0 ) /> | |
<cfset THIS.SessionManagement = true /> | |
<cfset THIS.SetClientCookies = false /> | |
<cfset this.datasource = "cfartgallery" /> | |
<cfset this.ormEnabled = true /> | |
<cfset this.ormSettings = { logsql : true } /> | |
<cfset this.invokeImplicitAccessor = true /> | |
<!--- ORM Setting not suggested for production use ---> | |
<cfset this.ormsettings = {autorebuild="true"}> | |
<!--- Define the page request properties. ---> | |
<cfsetting requesttimeout="20" showdebugoutput="false" enablecfoutputonly="false" /> | |
<cffunction name="OnApplicationStart" access="public" returntype="boolean" output="false" hint="Fires when the application is first created."> | |
<!--- Return out. ---> | |
<cfreturn true /> | |
</cffunction> | |
<cffunction name="OnSessionStart" access="public" returntype="void" output="false" hint="Fires when the session is first created."> | |
<!--- Return out. ---> | |
<cfreturn /> | |
</cffunction> | |
<cffunction name="OnRequestStart" access="public" returntype="boolean" output="false" hint="Fires at first part of page processing."> | |
<!--- Define arguments. ---> | |
<cfargument name="TargetPage" type="string" required="true" /> | |
<!--- Return out. ---> | |
<cfreturn true /> | |
</cffunction> | |
<cffunction name="OnRequest" access="public" returntype="void" output="true" hint="Fires after pre page processing is complete."> | |
<!--- Define arguments. ---> | |
<cfargument name="TargetPage" type="string" required="true" /> | |
<!--- Include the requested page. ---> | |
<cfinclude template="#ARGUMENTS.TargetPage#" /> | |
<!--- Return out. ---> | |
<cfreturn /> | |
</cffunction> | |
<cffunction name="OnRequestEnd" access="public" returntype="void" output="true" hint="Fires after the page processing is complete."> | |
<!--- Return out. ---> | |
<cfreturn /> | |
</cffunction> | |
<cffunction name="OnSessionEnd" access="public" returntype="void" output="false" hint="Fires when the session is terminated."> | |
<!--- Define arguments. ---> | |
<cfargument name="SessionScope" type="struct" required="true" /> | |
<cfargument name="ApplicationScope" type="struct" required="false" default="#StructNew()#" /> | |
<!--- Return out. ---> | |
<cfreturn /> | |
</cffunction> | |
<cffunction name="OnApplicationEnd" access="public" returntype="void" output="false" hint="Fires when the application is terminated."> | |
<!--- Define arguments. ---> | |
<cfargument name="ApplicationScope" type="struct" required="false" default="#StructNew()#" /> | |
<!--- Return out. ---> | |
<cfreturn /> | |
</cffunction> | |
<cffunction name="OnError" access="public" returntype="void" output="true" hint="Fires when an exception occures that is not caught by a try/catch."> | |
<!--- Define arguments. ---> | |
<cfargument name="Exception" type="any"required="true" /> | |
<cfargument name="EventName" type="string" required="false" default="" /> | |
<!--- Return out. ---> | |
<cfreturn /> | |
</cffunction> | |
</cfcomponent> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
component persistent="true" table="ART" schema="APP" output="false" | |
{ | |
/* properties */ | |
property name="ARTID" column="ARTID" type="numeric" ormtype="int" fieldtype="id"; | |
//property name="ARTISTID" column="ARTISTID" type="numeric" ormtype="int"; | |
property name="ARTNAME" column="ARTNAME" type="string" ormtype="string"; | |
property name="DESCRIPTION" column="DESCRIPTION" type="string" ormtype="clob"; | |
property name="PRICE" column="PRICE" type="numeric" ormtype="double"; | |
property name="LARGEIMAGE" column="LARGEIMAGE" type="string" ormtype="string"; | |
property name="MEDIAID" column="MEDIAID" type="numeric" ormtype="int"; | |
property name="ISSOLD" column="ISSOLD" type="numeric" ormtype="short"; | |
property name="ARTISTS" fieldtype="many-to-one" fkcolumn="ARTISTID" cfc="ARTISTS"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
component persistent="true" table="ARTISTS" schema="APP" output="false" | |
{ | |
/* properties */ | |
property name="ARTISTID" column="ARTISTID" type="numeric" ormtype="int" fieldtype="id"; | |
property name="FIRSTNAME" column="FIRSTNAME" type="string" ormtype="string"; | |
property name="LASTNAME" column="LASTNAME" type="string" ormtype="string"; | |
property name="ADDRESS" column="ADDRESS" type="string" ormtype="string"; | |
property name="CITY" column="CITY" type="string" ormtype="string"; | |
property name="STATE" column="STATE" type="string" ormtype="string"; | |
property name="POSTALCODE" column="POSTALCODE" type="string" ormtype="string"; | |
property name="EMAIL" column="EMAIL" type="string" ormtype="string"; | |
property name="PHONE" column="PHONE" type="string" ormtype="string"; | |
property name="FAX" column="FAX" type="string" ormtype="string"; | |
property name="THEPASSWORD" column="THEPASSWORD" type="string" ormtype="string"; | |
property name="ART" fieldtype="one-to-many" cfc="ART" fkcolumn="ARTISTID"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ---------------------------------------- */ | |
/* Default Styles */ | |
/* ---------------------------------------- */ | |
body { | |
font-family:arial,Arial, Helvetica, sans-serif; | |
margin:0; | |
} | |
header { | |
background-color:#336699; | |
color:#FFFFFF; | |
font-family:Lucida Grande; | |
font-size:2em; | |
font-style:italic; | |
text-shadow: 3px 3px 3px rgba(0, 0, 0, 1); | |
padding:10px 0 10px 10px; | |
} | |
footer { | |
background-color:#000000; | |
color:#FFFFFF; | |
font-size:.7em; | |
padding:5px 0 5px 0; | |
} | |
.dspDiv { | |
border:1px solid #000000; | |
} | |
/* ---------------------------------------- */ | |
/* Table Display */ | |
/* ---------------------------------------- */ | |
.dspTable { | |
border:1px solid #000000; | |
} | |
.dspTableBar { | |
color:#FFFFFF; | |
background-color:#336699; | |
} | |
/* ---------------------------------------- */ | |
/* Alternating Colors */ | |
/* ---------------------------------------- */ | |
.altColor1{ | |
color:#000000; | |
background-color:#ffffff; | |
} | |
.altColor2{ | |
color:#000000; | |
background-color:#dddddd; | |
} | |
/* ---------------------------------------- */ | |
/* Main Navigation Bar */ | |
/* ---------------------------------------- */ | |
.navbar { | |
background-color:#000000; | |
color:#FFFFFF; | |
font-size:.8em; | |
padding:5px 0 5px 0; | |
} | |
.navbar a { | |
color:#FFFFFF; | |
text-decoration:none; | |
padding:5px 0 5px 10px; | |
} | |
.navSelected a { | |
background-color:#ffff00; | |
} | |
.navbar a:hover | |
{ | |
color:#FFFFFF; | |
text-decoration:underline; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfparam name="rc.pageTitle" default="Page Title" > | |
<cfparam name="rc.applicationTtitle" default="CF Art Gallery ORM No Framework" > | |
<cfscript> | |
artistsList = entityLoad( "artists",{},{maxResults=3}); | |
</cfscript> | |
<cfoutput> | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> | |
<title>#rc.pageTitle# | #rc.applicationTtitle#</title> | |
<link rel="stylesheet" href="includes/default.css" type="text/css"> | |
</head> | |
<body bgcolor="##FFFFFF" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0"> | |
<header>#rc.applicationTtitle#</header> | |
<div class="navbar"> | |
<a href="index.cfm">Home</a> | | |
<a href="index.cfm">Home</a> | |
</div> | |
<br /> | |
<div id="content"> | |
<table align="center" border="0" cellpadding="4" cellspacing="0" class="dspTable"> | |
<tr class="dspTableBar"> | |
<th valign="top"> | |
First Name | |
</th> | |
<th valign="top"> | |
Last Name | |
</th> | |
</tr> | |
<cfset artistCount=0> | |
<cfloop array="#artistsList#" index="currArtist"> | |
<tr bgcolor="#IIf(artistCount Mod 2, DE('dddddd'), DE('ffffff'))#"> | |
<td valign="top"> | |
#currArtist.getFirstName()# | |
</td> | |
<td valign="top"> | |
#currArtist.getLastName()# | |
</td> | |
</tr> | |
<tr bgcolor="#IIf(artistCount Mod 2, DE('dddddd'), DE('ffffff'))#"> | |
<td valign="top" colspan="2" class="dspDiv"> | |
<div align="center"><b>Art</b></div> | |
<cfset artCount=0> | |
<cfloop array="#currArtist.getArt()#" index="currArt"> | |
<div style="background-color:###IIf(artCount Mod 2, DE('d0dae1'), DE('8aa4bd'))#"> | |
#currArt.getArtName()# | |
</div> | |
<cfset artCount+=1> | |
</cfloop> | |
</td> | |
<tr> | |
<cfset artistCount+=1> | |
</cfloop> | |
</table> | |
</div> | |
<br /> | |
<footer class="footer"> | |
<div align="center"> | |
© Copyright #year(now())# - CFTipsPlus.com | |
</div> | |
</footer> | |
</body> | |
</html> | |
</cfoutput> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment