PageRenderTime 4ms CodeModel.GetById 2ms app.highlight 0ms RepoModel.GetById 1ms app.codeStats 1ms

/examples/api_jsonutil/resources/artistMember.cfc

http://github.com/atuttle/Taffy
ColdFusion CFScript | 102 lines | 97 code | 5 blank | 0 comment | 0 complexity | 6afabea63a2d3613d0344751515c70e7 MD5 | raw file
  1<cfcomponent extends="taffy.core.resource" taffy_uri="/artist/{id}">
  2
  3	<cffunction name="get" access="public" output="false">
  4		<cfargument name="id" type="numeric" required="true" />
  5		<cfset var q = ""/>
  6		<cfquery name="q" datasource="cfartgallery">
  7			select * from artists where artistId = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.id#" />
  8		</cfquery>
  9		<cfreturn representationOf(q).withStatus(200) />
 10	</cffunction>
 11
 12	<cffunction name="put" access="public" output="false">
 13		<cfargument name="id" type="numeric" required="true" />
 14		<cfargument name="firstname" type="string" required="false" default="" />
 15		<cfargument name="lastname" type="string" required="false" default="" />
 16		<cfargument name="address" type="string" required="false" default="" />
 17		<cfargument name="city" type="string" required="false" default="" />
 18		<cfargument name="state" type="string" required="false" default="" />
 19		<cfargument name="postalcode" type="string" required="false" default="" />
 20		<cfargument name="email" type="string" required="false" default="" />
 21		<cfargument name="phone" type="string" required="false" default="" />
 22		<cfargument name="fax" type="string" required="false" default="" />
 23		<cfargument name="thepassword" type="string" required="false" default="" />
 24		<cfset var q = "" />
 25		<cfquery name="q" datasource="cfartgallery">
 26			update artists
 27			set artistid=artistid
 28				<cfif len(arguments.firstname)>
 29					,firstname = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.firstname#" />
 30				</cfif>
 31				<cfif len(arguments.lastname)>
 32					,lastname = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.lastname#" />
 33				</cfif>
 34				<cfif len(arguments.address)>
 35					,address = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.address#" />
 36				</cfif>
 37				<cfif len(arguments.city)>
 38					,city = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.city#" />
 39				</cfif>
 40				<cfif len(arguments.state)>
 41					,state = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.state#" />
 42				</cfif>
 43				<cfif len(arguments.postalcode)>
 44					,postalcode = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.postalcode#" />
 45				</cfif>
 46				<cfif len(arguments.email)>
 47					,email = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.email#" />
 48				</cfif>
 49				<cfif len(arguments.phone)>
 50					,phone = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.phone#" />
 51				</cfif>
 52				<cfif len(arguments.fax)>
 53					,fax = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.fax#" />
 54				</cfif>
 55				<cfif len(arguments.thepassword)>
 56					,thepassword = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.thepassword#" />
 57				</cfif>
 58				where artistid = <cfqueryparam cfsqltype="cf_sql_numeric" value="#arguments.id#" />
 59		</cfquery>
 60		<cfreturn noData().withStatus(200) />
 61	</cffunction>
 62
 63	<cffunction name="post" access="public" output="false">
 64		<cfargument name="firstname" type="string" required="false" default="" />
 65		<cfargument name="lastname" type="string" required="false" default="" />
 66		<cfargument name="address" type="string" required="false" default="" />
 67		<cfargument name="city" type="string" required="false" default="" />
 68		<cfargument name="state" type="string" required="false" default="" />
 69		<cfargument name="postalcode" type="string" required="false" default="" />
 70		<cfargument name="email" type="string" required="false" default="" />
 71		<cfargument name="phone" type="string" required="false" default="" />
 72		<cfargument name="fax" type="string" required="false" default="" />
 73		<cfargument name="thepassword" type="string" required="false" default="" />
 74		<cfset var q = "" />
 75		<cfquery name="q" datasource="cfartgallery">
 76			insert into artists (firstname,lastname,address,city,state,postalcode,email,phone,fax,thepassword)
 77			values (
 78				<cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.firstname#" />
 79				,<cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.lastname#" />
 80				,<cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.address#" />
 81				,<cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.city#" />
 82				,<cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.state#" />
 83				,<cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.postalcode#" />
 84				,<cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.email#" />
 85				,<cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.phone#" />
 86				,<cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.fax#" />
 87				,<cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.thepassword#" />
 88			)
 89		</cfquery>
 90		<cfreturn noData().withStatus(201) />
 91	</cffunction>
 92
 93	<cffunction name="delete" access="public" output="false">
 94		<cfargument name="id" type="numeric" required="true" />
 95		<cfset var q = "" />
 96		<cfquery name="q" datasource="cfartgallery">
 97			delete from artists where artistid = <cfqueryparam cfsqltype="cf_sql_numeric" value="#arguments.id#" />
 98		</cfquery>
 99		<cfreturn noData().withStatus(200) />
100	</cffunction>
101
102</cfcomponent>