<cfcomponent hint="I am the base DAO object for the object. I am generated. DO NOT EDIT ME (but feel free to delete me)." extends="reactor.base.abstractDao" > <cfset variables.signature = "" /> <cffunction name="save" access="public" hint="I create or update a record." output="false" returntype="void"> <cfargument name="to" hint="I am the transfer object for " required="yes" /> <cfif IsNumeric(arguments.to.) AND Val(arguments.to.) AND > <cfset update(arguments.to) /> <cfelse> <cfset create(arguments.to) /> </cfif> <cfif Len(arguments.to.) AND exists(arguments.to)> <cfset update(arguments.to) /> <cfelse> <cfset create(arguments.to) /> </cfif> <cfset create(arguments.to) /> </cffunction> <cffunction name="exists" access="public" hint="I check to see if the object exists." output="false" returntype="any" _returntype="boolean"> <cfargument name="to" hint="I am the transfer object for which will be checked." required="yes" type="any" _type="reactor.project..To.To" /> <cfset var qExists = 0 /> <cfset var Gateway = _getReactorFactory().createGateway("") /> <cfset qExists = Gateway.getByFields( = arguments.to. , ) /> <cfif qExists.recordCount> <cfreturn true /> <cfelse> <cfreturn false /> </cfif> </cffunction> <cffunction name="create" access="public" hint="I create a object." output="false" returntype="void"> <cfargument name="to" hint="I am the transfer object for " required="yes" type="any" _type="reactor.project..To.To"/> <cfset var Convention = getConventions() /> <cfset var qCreate = 0 /> <cfif Convention.supportsSequences()> <cfquery name="qCreate" datasource="#_getConfig().getDsn()#" username="#_getConfig().getUsername()#" password="#_getConfig().getPassword()#"> #Convention.getNextSequenceSyntax("")# </cfquery> <cfset arguments.to. = qCreate.ID /> </cfif> <cfquery name="qCreate" datasource="#_getConfig().getDsn()#" username="#_getConfig().getUsername()#" password="#_getConfig().getPassword()#"> INSERT INTO #Convention.FormatObjectName(getObjectMetadata())# ( <cfif (NOT Convention.supportsIdentity()) OR (false AND Convention.supportsSequences())> #Convention.formatInsertFieldName('', '')# , </cfif> ) VALUES ( <cfif (NOT Convention.supportsIdentity()) OR (false AND Convention.supportsSequences())> <cfqueryparam cfsqltype="" maxlength="" scale="" value=" #Left(arguments.to., 23)#-#Right(arguments.to., 12)# #arguments.to.# " null="#Iif(NOT Len(arguments.to.), DE(true), DE(false))#" /> , </cfif> ) <cfif Convention.supportsMultiStatementQueries() AND Convention.supportsIdentity() > #Convention.lastInsertedIdSyntax(getObjectMetadata())# </cfif> </cfquery> <cfif NOT Convention.supportsMultiStatementQueries() AND Convention.supportsIdentity() > <cfquery name="qCreate" datasource="#_getConfig().getDsn()#" username="#_getConfig().getUsername()#" password="#_getConfig().getPassword()#"> #Convention.lastInsertedIdSyntax(getObjectMetadata())# </cfquery> </cfif> <cfif Convention.supportsIdentity() AND qCreate.recordCount> <cfset arguments.to. = qCreate.id /> </cfif> </cffunction> <cffunction name="read" access="public" hint="I read a object." output="false" returntype="void"> <cfargument name="to" hint="I am the transfer object for which will be populated." required="yes" type="any" _type="reactor.project..To.To"/> <cfargument name="loadFieldList" hint="I am an optional list of fields to load the record based on. If not provided I default to the primary key values." required="no" type="any" _type="string" default="" /> <cfset var qRead = 0 /> <cfset var Gateway = _getReactorFactory().createGateway("") /> <cfset var Query = 0 /> <cfset var field = "" /> <cfset var criteria = "" /> <cfif Len(arguments.loadFieldList)> <cfset Query = Gateway.createQuery() /> <cfloop list="#arguments.loadFieldList#" index="field"> <cfset Query.getWhere().isEqual("", field, arguments.to[field]) /> <cfset criteria = listAppend( criteria, "#field#=#arguments.to[field]#" ) /> </cfloop> <cfset qRead = Gateway.getByQuery(Query,true) /> <cfelse> <cfset criteria = listAppend( criteria, "=#arguments.to.#" ) /> <cfset qRead = Gateway.getByFields( = arguments.to. , ) /> </cfif> <cfif qRead.recordCount IS 1> <cfset arguments.to. = qRead. qRead. /> <cfset arguments.to. = qRead. /> <cfelseif qRead.recordCount GT 1> <cfthrow message="Ambiguous Record" detail="Your request matched more than one record. #criteria#" type="Reactor.Record.AmbiguousRecord" /> <cfelseif qRead.recordCount IS 0> <cfthrow message="No Matching Record" detail="Your request matched no records. #criteria#" type="Reactor.Record.NoMatchingRecord" /> </cfif> </cffunction> <cffunction name="update" access="public" hint="I update a object." output="false" returntype="void"> <cfargument name="to" hint="I am the transfer object for which will be used to update a record in the table." required="yes" type="any" _type="reactor.project..To.To" /> <cfset var Convention = getConventions() /> <cfset var qUpdate = 0 /> <cfquery name="qUpdate" datasource="#_getConfig().getDsn()#" username="#_getConfig().getUsername()#" password="#_getConfig().getPassword()#"> UPDATE #Convention.FormatObjectName(getObjectMetadata())# SET #Convention.formatUpdateFieldName('')# = <cfqueryparam cfsqltype="" maxlength="" scale="" value=" #Left(arguments.to., 23)#-#Right(arguments.to., 12)# #arguments.to.# " null="#Iif(NOT Len(arguments.to.), DE(true), DE(false))#" /> , WHERE #Convention.formatUpdateFieldName('')# = <cfqueryparam cfsqltype="" maxlength="" scale="" value=" #Left(arguments.to., 23)#-#Right(arguments.to., 12)# #arguments.to.# " null="#Iif(NOT Len(arguments.to.), DE(true), DE(false))#" /> AND </cfquery> </cffunction> <cffunction name="delete" access="public" hint="I delete a record in the table." output="false" returntype="void"> <cfargument name="to" hint="I am the transfer object for which will be used to delete from the table." required="yes" type="any" _type="reactor.project..To.To" /> <cfset var Convention = getConventions() /> <cfset var qDelete = 0 /> <cfquery name="qDelete" datasource="#_getConfig().getDsn()#" username="#_getConfig().getUsername()#" password="#_getConfig().getPassword()#"> DELETE FROM #Convention.FormatObjectName(getObjectMetadata())# WHERE #Convention.formatUpdateFieldName('', '')# = <cfqueryparam cfsqltype="" maxlength="" scale="" value=" #Left(arguments.to., 23)#-#Right(arguments.to., 12)# #arguments.to.# " null="#Iif(NOT Len(arguments.to.), DE(true), DE(false))#" /> AND </cfquery> </cffunction> </cfcomponent>