Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <cfcomponent displayname="User">
- <cffunction name="getUser" access="public" returntype="query" output="0">
- <cfargument name="userId" type="numeric" required="yes" default="0">
- <cfset var thisUserId = trim(arguments.userId)>
- <cfif isValid("integer",thisUserId)>
- <cfquery name="qryGetUser" datasource="#application.DSN#">
- SELECT * FROM tblUsers
- WHERE user_id = <cfqueryparam cfsqltype="cf_sql_integer" value="#thisUserId#">
- </cfquery>
- <cfelse>
- <--- Return an empty query if the argument is not an integer --">
- <cfquery name="qryGetUser" datasource="#application.DSN#">
- SELECT * FROM tblUsers WHERE user_id = 0
- </cfquery>
- </cfif>
- <cfreturn qryGetUser>
- </cffunction>
- <cffunction name="updateUser" access="public" returntype="boolean" output="0">
- <cfargument name="userStructure" type="struct" required="yes">
- <cfscript>
- valueSet = "";
- for (key in myStruct) {
- if(myStruct[key] NEQ ""){
- valueSet = listAppend(valueSet,key & "='" & utilityObj.sqlSafe(myStruct[key]) & "'");
- }else{
- valueSet = listAppend(valueSet,key & "='" & myStruct[key] & "'");
- }
- }
- </cfscript>
- <cftry>
- <cfstoredproc datasource="#application.DSN#" procedure="dbo.sp_update_user">
- <cfprocparam value="#arguments.userId#" cfsqltype="cf_sql_varchar">
- <cfprocparam value="#valueSet#" cfsqltype="cf_sql_varchar">
- <cfprocresult name="qA">
- </cfstoredproc>
- <cfcatch type="database">
- <cfoutput>#cfcatch.detail#</cfoutput><cfabort>
- </cfcatch>
- </cftry>
- <cfreturn>
- </cffunction>
- </cfcomponent>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement