CFLib.org – Common Function Library Project

queryh(query)

Last updated May 1, 2011

author

Kalyan Dhar

Version: 2 | Requires: CF7 | Library: DataManipulationLib

Description:
Returns a query with any string values sanitized by HTMLEditFormat. Values of the type varchar,char,nvarchar,text,ntext are modified.

Return Values:
Returns a query.

Example:

Suppose you have some html tag in Groupname or in groupDEsc
Then you can do this 

<cfquery name="groupList" datasource="TestDSN">
	select 
		ID, 
		GroupTypeID, 
		GroupName, 
		GroupDesc
	from
		groups
	where
		tiRecordStatus = 1
</cfquery>
<!---Now call queryh() function to escape html tag--->
<cfset groupList = queryh(groupList) />

This function will automaticaly took those column where tag can be inserted.
then escape those tags

Parameters:

Name Description Required
query Query to modify. Yes

Full UDF Source:

<!---
 Returns a query with any string values sanitized by HTMLEditFormat.
 v2 modified by Raymond Camden
 
 @param query 	 Query to modify. (Required)
 @return Returns a query. 
 @author Kalyan Dhar (kalyan.cse.jis@gmail.com) 
 @version 2, May 1, 2011 
--->
<cffunction name="queryh" returnType="query" description="returns query after senitize descriptive fields">
	<cfargument name="query" type="query" required="true">

	<cfset var list = "" />
	<cfset var listSelect = "varchar,char,nvarchar,text,ntext" />
	<cfset var column = "">
	<cfset var metadata = "">
	<cfset var type = "">
	
	<cfloop list="#query.ColumnList#" index="column">
		<cfscript>
		metadata = query.getMetaData();
		type = metadata.getColumnTypeName(query.findColumn(column));
		</cfscript>

		<cfif listFindNoCase(listSelect,type)>
			<cfset list = listAppend(list,column)>
		</cfif>
	</cfloop>
	
	<cfif listLen(list)>
		<cfloop query="query">
			<cfloop list="#list#" index="column">
				<cfset querySetCell(query, column, htmlEditFormat(query[column][currentRow]),currentRow)>
			</cfloop>
		</cfloop>
	</cfif>

	<cfreturn query />
</cffunction>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson