PageRenderTime 21ms CodeModel.GetById 18ms app.highlight 0ms RepoModel.GetById 2ms app.codeStats 0ms

/examples/api_jsonxml/resources/artistCollection.cfc

http://github.com/atuttle/Taffy
ColdFusion CFScript | 59 lines | 55 code | 4 blank | 0 comment | 0 complexity | 8937c175adc80309481bd204c4205868 MD5 | raw file
 1<cfcomponent extends="taffy.core.resource" taffy_uri="/artists">
 2
 3	<cffunction name="get" access="public" output="false">
 4		<cfset var q = "" />
 5		<cfquery name="q" datasource="cfartgallery">
 6			select * from artists
 7		</cfquery>
 8		<cfreturn representationOf(q).withStatus(200) />
 9	</cffunction>
10
11	<cffunction name="post" access="public" output="false">
12		<cfargument name="firstname" type="string" required="false" default="" />
13		<cfargument name="lastname" type="string" required="false" default="" />
14		<cfargument name="address" type="string" required="false" default="" />
15		<cfargument name="city" type="string" required="false" default="" />
16		<cfargument name="state" type="string" required="false" default="" />
17		<cfargument name="postalcode" type="string" required="false" default="" />
18		<cfargument name="email" type="string" required="false" default="" />
19		<cfargument name="phone" type="string" required="false" default="" />
20		<cfargument name="fax" type="string" required="false" default="" />
21		<cfargument name="thepassword" type="string" required="false" default="" />
22		<cfset var q = "" />
23		<cfquery name="q" datasource="cfartgallery">
24			insert into artists (firstname,lastname,address,city,state,postalcode,email,phone,fax,thepassword)
25			values (
26				<cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.firstname#" />,
27				<cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.lastname#" />,
28				<cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.address#" />,
29				<cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.city#" />,
30				<cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.state#" />,
31				<cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.postalcode#" />,
32				<cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.email#" />,
33				<cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.phone#" />,
34				<cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.fax#" />,
35				<cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.thepassword#" />
36			)
37		</cfquery>
38		<cfquery name="q" datasource="cfartgallery">
39			select * from artists
40			where
41				firstname = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.firstname#" />
42				and lastname = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.lastname#" />
43				and address = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.address#" />
44				and city = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.city#" />
45				and state = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.state#" />
46				and postalcode = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.postalcode#" />
47				and email = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.email#" />
48				and phone = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.phone#" />
49				and fax = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.fax#" />
50				and thepassword = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.thepassword#" />
51		</cfquery>
52		<cfreturn representationOf(q).withStatus(200) />
53	</cffunction>
54
55	<!---
56		The DELETE and PUT verbs are not implemented, so those actions are not permitted.
57	 --->
58
59</cfcomponent>