Question
Another CFC question
Ok, so I'm still working on getting this CFC thing down... :)
Azadi gave me some good pointers, and I've tried to follow them. Now I want
to see if I can add something. I have:
<cfcomponent displayname="duplicate" hint="Duplicates local club
tournaments">
<!--- This function retrieves all customers from the database --->
<cffunction name="getinfo"
hint="Gets all tournament info from the database" returntype="boolean"
output="no">
<cfargument name="tid" required="yes" type="numeric">
<cfset var DuplicateTournamentList = "">
<cfset var result = true>
<!--- Sends TournID to have the new tournament date calculated --->
<cfinvoke component="components.dateCalc" method="calcDate"
returnvariable="nDate">
<cfinvokeargument name="id" value="#arguments.tid#">
</cfinvoke>
<cftry>
<cfquery name="DuplicateTournamentList" datasource="SalleBoise">
INSERT INTO clubtournaments( TournName, TournDesc, TournFoilEvent,
TournEpeeEvent, EventType, TournDateTime, TournDuplicated )
SELECT TournName, TournDesc, TournFoilEvent, TournEpeeEvent, EventType,
DATE_ADD( TournDateTime, INTERVAL 2
MONTH ) AS TournDateTime, 0 AS TournDuplicated
FROM clubtournaments
WHERE TournID = <cfqueryparam cfsqltype="cf_sql_integer"
value="#arguments.tid#">
</cfquery>
Which does a good job of duplicating the event, but the problem is I need to
have the new event on the 1st Saturday, 2 months from the original event.
I worked out, with the help of another CF person, something along the lines
of:
<cfcomponent displayname="DOM" hint="Sets new date for new tournament">
<cffunction name="calcDate" access="public" returntype="string"
hint="Returns 1st Saturday of Month">
<cfargument name="id" type="date" required="yes">
<cfquery name="GetTournDate" datasource="SalleBoise">
select TournDateTime
from clubtournaments
where TournID=<cfqueryparam cfsqltype="cf_sql_integer"
value="#arguments.id#">
</cfquery>
<cfset var testDay =
dateformat(GetTournDate.TournDateTime,"mm/dd/yyyy")>
<cfset var left_testDay=left(testDay,2)>
<cfset var right_testDay=right(testDay,4)>
<cfset var combo_testDay="#left_testDay#" & "/" & "01" & "/" &
"#right_testDay#">
<cfset var NewtestDay=dateadd("m",2,combo_testDay)>
<cfloop condition="dayOfWeek(NewtestDay) NEQ 7">
<cfset NewtestDay = dateAdd("d",NewtestDay,1)>
</cfloop>
<cfset var newDate=NewtestDay>
<cfreturn newDate>
</cffunction>
</cfcomponent>
Now, I have 3 questions:
1) Can I call invoke a CFC from within a CFC such as <cfinvoke
component="components.dateCalc" method="calcDate" returnvariable="nDate">
<cfinvokeargument name="id" value="#arguments.tid#">
</cfinvoke>
2) How can I determine if the 2nd CFC is processing data?
3) With the inputting of data in the 1st CFC, how can I get the newly
calculated data to be input rather than the DATE_ADD( TournDateTime,
INTERVAL 2
MONTH ) AS TournDateTime
Thanks!!
Azadi gave me some good pointers, and I've tried to follow them. Now I want
to see if I can add something. I have:
<cfcomponent displayname="duplicate" hint="Duplicates local club
tournaments">
<!--- This function retrieves all customers from the database --->
<cffunction name="getinfo"
hint="Gets all tournament info from the database" returntype="boolean"
output="no">
<cfargument name="tid" required="yes" type="numeric">
<cfset var DuplicateTournamentList = "">
<cfset var result = true>
<!--- Sends TournID to have the new tournament date calculated --->
<cfinvoke component="components.dateCalc" method="calcDate"
returnvariable="nDate">
<cfinvokeargument name="id" value="#arguments.tid#">
</cfinvoke>
<cftry>
<cfquery name="DuplicateTournamentList" datasource="SalleBoise">
INSERT INTO clubtournaments( TournName, TournDesc, TournFoilEvent,
TournEpeeEvent, EventType, TournDateTime, TournDuplicated )
SELECT TournName, TournDesc, TournFoilEvent, TournEpeeEvent, EventType,
DATE_ADD( TournDateTime, INTERVAL 2
MONTH ) AS TournDateTime, 0 AS TournDuplicated
FROM clubtournaments
WHERE TournID = <cfqueryparam cfsqltype="cf_sql_integer"
value="#arguments.tid#">
</cfquery>
Which does a good job of duplicating the event, but the problem is I need to
have the new event on the 1st Saturday, 2 months from the original event.
I worked out, with the help of another CF person, something along the lines
of:
<cfcomponent displayname="DOM" hint="Sets new date for new tournament">
<cffunction name="calcDate" access="public" returntype="string"
hint="Returns 1st Saturday of Month">
<cfargument name="id" type="date" required="yes">
<cfquery name="GetTournDate" datasource="SalleBoise">
select TournDateTime
from clubtournaments
where TournID=<cfqueryparam cfsqltype="cf_sql_integer"
value="#arguments.id#">
</cfquery>
<cfset var testDay =
dateformat(GetTournDate.TournDateTime,"mm/dd/yyyy")>
<cfset var left_testDay=left(testDay,2)>
<cfset var right_testDay=right(testDay,4)>
<cfset var combo_testDay="#left_testDay#" & "/" & "01" & "/" &
"#right_testDay#">
<cfset var NewtestDay=dateadd("m",2,combo_testDay)>
<cfloop condition="dayOfWeek(NewtestDay) NEQ 7">
<cfset NewtestDay = dateAdd("d",NewtestDay,1)>
</cfloop>
<cfset var newDate=NewtestDay>
<cfreturn newDate>
</cffunction>
</cfcomponent>
Now, I have 3 questions:
1) Can I call invoke a CFC from within a CFC such as <cfinvoke
component="components.dateCalc" method="calcDate" returnvariable="nDate">
<cfinvokeargument name="id" value="#arguments.tid#">
</cfinvoke>
2) How can I determine if the 2nd CFC is processing data?
3) With the inputting of data in the 1st CFC, how can I get the newly
calculated data to be input rather than the DATE_ADD( TournDateTime,
INTERVAL 2
MONTH ) AS TournDateTime
Thanks!!
