Last active
December 25, 2015 06:49
-
-
Save Macagare/6934747 to your computer and use it in GitHub Desktop.
normalize query string for query of queries
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
<cffunction name="normalizeChar" returntype="string" hint="Replaces characters with their non accented closest equivalents" output="true"> | |
<cfargument name="str" type="string" required="true" /> | |
<cfreturn ReplaceList( str,"á,é,í,ó,ú,ý,à,è,ì,ò,ù,â,ê,î,ô,û,ã,ñ,õ,ä,ë,ï,ö,ü,ÿ,À,È,Ì,Ò,Ù,Á,É,Í,Ó,Ú,Ý,Â,Ê,Î,Ô,Û,Ã,Ñ,Õ,Ä,Ë,Ï,Ö,Ü", | |
"a,e,i,o,y,u,a,e,i,o,u,a,e,i,o,u,a,n,o,a,e,i,o,u,y,A,E,I,O,U,A,E,I,O,U,Y,A,E,I,O,U,A,N,O,A,E,I,O,U") /> | |
</cffunction> | |
<cffunction name="normalizeColumn" returntype="query" output="true" hint="normalize single column and add new column [column]_norm"> | |
<cfargument name="qSource" type="query" required="true" /> | |
<cfargument name="column" type="string" required="true" /> | |
<cfset var normColumn = arguments.column & "_norm" /> | |
<cfif len(arguments.column) and listFindNoCase(arguments.qSource.columnList, arguments.column) > | |
<cfset QueryAddColumn(arguments.qSource, normColumn, ArrayNew(1) ) /> | |
<cfloop query="arguments.qSource"> | |
<cfset QuerySetCell(arguments.qSource, normColumn, | |
lcase( normalizeChar(arguments.qSource[arguments.column][arguments.qSource.currentRow]) ), | |
arguments.qSource.currentRow) /> | |
</cfloop> | |
</cfif> | |
<cfreturn arguments.qSource /> | |
</cffunction> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment