Just had some assistance to tweek it down a little more from one of you
great guys! Thanks... here is the final version we settled on.
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to
[email protected] with the words 'unsubscribe cfcdev' as the subject of the
email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting
(www.cfxhosting.com).
An archive of the CFCDev list is available at
www.mail-archive.com/[email protected]
<cfcomponent displayname="Query Object" output="false">
<!--- This CFC is the property of SOSensible. You may use it free of
charge under standard
GNU Open Source Lisc. practices. You may use it for personal or
commercial and modify it
to your needs at no charge. The only exceptions are that you may not
remove this notice and
you must not hold our company or employees liable in any way for it's
performance. If you enhance
this component we request that you send a copy of your enhancements to
us at [EMAIL PROTECTED]
for our review so that the spirit of this open source object will
continue to grow for the
community at large.
www.sosensible.com --->
<cfset variables.query = queryNew("empty","VarChar")>
<cfset variables.currentRow = 0>
<cfset variables.recordCount = 0>
<cfset variables.columnList = "">
<cfset variables.keyField = "">
<cfset variables.keyNumeric = TRUE>
<cfset this.column = structNew()>
<cffunction name="init" access="public" returntype="oquery"
output="false">
<cfargument name="query" type="query" required="yes">
<cfargument name="keyField" type="string" required="no"
default="">
<cfargument name="keyNumeric" type="boolean" required="no"
default="TRUE">
<cfscript>
variables.query = duplicate(arguments.query);
variables.columnList = arguments.query.columnList;
variables.currentRow = 1;
variables.keyField = arguments.keyField;
variables.keyNumeric = arguments.keyNumeric;
variables.recordCount = arguments.query.recordCount;
</cfscript>
<cfreturn this>
</cffunction>
<cffunction name="getColumn" access="public" returntype="any"
output="No">
<cfargument name="columnName" type="string" required="Yes">
<cfreturn
variables.query[arguments.columnName][variables.currentRow]>
</cffunction>
<cffunction name="getColumnList" access="public" returntype="numeric"
output="false">
<cfreturn variables.columnList>
</cffunction>
<cffunction name="getCurrentRecord" access="public" returntype="query"
output="false">
<cfset var local = "">
<cfquery name="local.myReturn" dbtype="query">
SELECT *
FROM variables.query
WHERE #variables.keyField# = <cfif
variables.keyNumeric>#evaluate(variables.keyField)#<cfelse>'#evaluate(variables.keyField)#'</cfif>
</cfquery>
<cfreturn local.myReturn>
</cffunction>
<cffunction name="getCurrentRow" access="public" returntype="numeric"
output="false">
<cfreturn variables.currentRow>
</cffunction>
<cffunction name="getRecordCount" access="public" returntype="numeric"
output="false">
<cfreturn variables.recordCount>
</cffunction>
<cffunction name="getRecord" access="public" returntype="query"
output="false">
<cfargument name="key" type="string" required="No" default="">
<cfset var local = structNew()>
<cfif arguments.key EQ "">
<cfset local.myKey =
variables.query[variables.keyField][variables.currentRow]>
<cfelse>
<cfset local.myKey = 0>
<cfloop index="local.row" from="1"
to="#variables.recordCount#">
<cfset local.value =
evaluate("variables.query.#variables.keyField#[local.row]")>
<cfif local.value EQ arguments.key>
<cfset local.myKey = local.value>
<cfset local.row =
variables.recordCount>
</cfif>
</cfloop>
</cfif>
<cfquery name="local.myReturn" dbtype="query">
SELECT *
FROM variables.query
WHERE #variables.keyField# = <cfif
variables.keyNumeric>#local.myKey#<cfelse>'#local.myKey#'</cfif>
</cfquery>
<cfreturn local.myReturn>
</cffunction>
<cffunction name="getRecordSet" access="public" returntype="query"
output="false">
<cfreturn variables.query>
</cffunction>
<cffunction name="hasNext" access="public" returntype="boolean"
output="false">
<cfreturn (variables.currentRow lt variables.query.recordCount)>
</cffunction>
<cffunction name="hasPrevious" access="public" returntype="boolean"
output="false">
<cfreturn (variables.currentRow gt 1)>
</cffunction>
<cffunction name="isFirst" access="public" returntype="boolean"
output="false">
<cfreturn (variables.currentRow EQ 1)>
</cffunction>
<cffunction name="isLast" access="public" returntype="boolean"
output="false">
<cfreturn (variables.currentRow EQ variables.query.recordCount)>
</cffunction>
<cffunction name="moveFirst" access="public" returntype="boolean"
output="false">
<cfif variables.recordCount GTE 1>
<cfset variables.currentRow = 1>
<cfreturn TRUE>
</cfif>
<cfreturn FALSE>
</cffunction>
<cffunction name="moveLast" access="public" returntype="boolean"
output="false">
<cfif variables.recordCount GTE 1>
<cfset variables.currentRow = variables.recordCount>
<cfreturn TRUE>
</cfif>
<cfreturn FALSE>
</cffunction>
<cffunction name="moveNext" access="public" returntype="boolean"
output="false">
<cfif hasNext()>
<cfset variables.currentRow = variables.currentRow + 1>
<cfreturn TRUE>
</cfif>
<cfreturn FALSE>
</cffunction>
<cffunction name="movePosition" access="public" returntype="boolean"
output="false">
<cfargument name="position" type="numeric" required="Yes">
<cfif arguments.position LTE getRecordCount()>
<cfset variables.currentRow = arguments.position>
<cfreturn TRUE>
</cfif>
<cfreturn FALSE>
</cffunction>
<cffunction name="movePrevious" access="public" returntype="boolean"
output="false">
<cfif hasPrevious()>
<cfset variables.currentRow = variables.currentRow - 1>
<cfreturn TRUE>
</cfif>
<cfreturn FALSE>
</cffunction>
<!--- To add functions...
addRecord()
deleteRecord()
updateRecord()
filter()
isFiltered()
clearFilter()
columnType()
isQuotedColumn() ...this would be used to know if query interaction for
this type of column requires quotes or not, could help automate dynamic queries
sort() ...note-not sure if QofQ can do a multicolumn sort
addDynmicColumn() ...i.e. "dynamically calculated columns" that return as
standard data columns. (and in CFMX7 you can have data types for these)
getRecordRange(start,end)
--->
</cfcomponent>
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to
[email protected] with the words 'unsubscribe cfcdev' as the subject of the
email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting
(www.cfxhosting.com).
An archive of the CFCDev list is available at
www.mail-archive.com/[email protected]