Created
July 27, 2012 23:01
-
-
Save wellercs/3190924 to your computer and use it in GitHub Desktop.
Easy method for setting cfqueryparam null attribute
This file contains hidden or 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 name="utilities" output="false" hint="I provide various utility functionality"> | |
<cffunction name="init" access="public" returntype="any" output="false" hint="Initializes the Service"> | |
<cfreturn this /> | |
</cffunction> | |
<cffunction name="isNullFormat" access="remote" returntype="any" output="false" hint="I return whether something is null"> | |
<cfargument name="input" type="any" required="true" /> | |
<cfset var inputdatatype = ""> | |
<cftry> | |
<cfset inputdatatype = arguments.input.GetClass().GetName() /> | |
<cfif inputdatatype IS "java.lang.String" AND NOT len(trim(arguments.input))> | |
<cfreturn true /> | |
<cfelseif inputdatatype IS "java.lang.String" AND len(trim(arguments.input))> | |
<cfreturn false /> | |
<cfelseif inputdatatype IS "coldfusion.runtime.Struct" AND StructIsEmpty(arguments.input)> | |
<cfreturn true /> | |
<cfelseif inputdatatype IS "coldfusion.runtime.Struct" AND NOT StructIsEmpty(arguments.input)> | |
<cfreturn false /> | |
<cfelseif inputdatatype IS "coldfusion.runtime.Array" AND NOT ArrayLen(arguments.input)> | |
<cfreturn true /> | |
<cfelseif inputdatatype IS "coldfusion.runtime.Array" AND ArrayLen(arguments.input)> | |
<cfreturn false /> | |
<cfelseif inputdatatype IS "coldfusion.sql.QueryTable" AND NOT arguments.input.recordcount> | |
<cfreturn true /> | |
<cfelseif inputdatatype IS "coldfusion.sql.QueryTable" AND arguments.input.recordcount> | |
<cfreturn false /> | |
<cfelse> | |
<cfthrow type="customerror" message="Unknown data type." detail="Input: #arguments.input#. Data type received: #inputdatatype#"> | |
</cfif> | |
<cfcatch type="any"> | |
<!--- fail ---> | |
</cfcatch> | |
</cftry> | |
</cffunction> | |
</cfcomponent> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment