Question
CFC oddness....
Ok, I have the following CFC:
<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>
<cfset var NewTournDate = calcDate(arguments.tid)>
<cftry>
<cfquery name="DuplicateTournamentList" datasource="SalleBoise">
INSERT INTO clubtournaments( TournName, TournDesc, TournFoilEvent,
TournEpeeEvent, EventType, TournDateTime, TournDuplicated )
SELECT TournName, TournDesc, TournFoilEvent, TournEpeeEvent, EventType,
<cfqueryparam cfsqltype="cf_sql_date" value="#NewTournDate#"> AS
TournDateTime, 0 AS TournDuplicated
FROM clubtournaments
WHERE TournID = <cfqueryparam cfsqltype="cf_sql_integer"
value="#arguments.tid#">
</cfquery>
<cfcatch type="any">
<cfset result = false>
</cfcatch>
</cftry>
<cfreturn result />
</cffunction>
<cffunction name="calcDate" access="public" returntype="date" hint="Returns
1st Saturday of Month">
<cfargument name="id" type="numeric" required="yes">
<cfset var GetTournDate = "">
<cfset var tourndate = "">
<cfset var FirstOfMonth2MonthsAhead = "">
<cfset NewTournDate = "">
<cfquery name="GetTournDate" datasource="SalleBoise">
select TournDateTime
from clubtournaments
where TournID=<cfqueryparam cfsqltype="cf_sql_integer"
value="#arguments.id#">
</cfquery>
<cfset tourndate = GetTournDate.TournDateTime>
<cfset FirstOfMonth2MonthsAhead = createdatetime(year(dateadd('m', 2,
tourndate)), month(dateadd('m', 2, tourndate)), day(tourndate),
hour(tourndate),
minute(tourndate), second(tourndate))>
<cfset NewTournDate = dateadd('d',
7-dayofweek(FirstOfMonth2MonthsAhead), FirstOfMonth2MonthsAhead)>
<cfreturn NewTournDate />
</cffunction>
</cfcomponent>
The problem seems to be happening when the new info is added to the
database. The new DATE is added correctly, but not the TIME... If I do a
dump of whats being stored in NewTournDate, it shows:
{ts '2008-07-05 15:00:00'}
I have my MySql field that I'm storing this info as a Timestamp, and thought
that should be fine. But the time keeps defaulting to 12:00:00, instead of
the 15:00:00 as shown.
Why is this happening?
<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>
<cfset var NewTournDate = calcDate(arguments.tid)>
<cftry>
<cfquery name="DuplicateTournamentList" datasource="SalleBoise">
INSERT INTO clubtournaments( TournName, TournDesc, TournFoilEvent,
TournEpeeEvent, EventType, TournDateTime, TournDuplicated )
SELECT TournName, TournDesc, TournFoilEvent, TournEpeeEvent, EventType,
<cfqueryparam cfsqltype="cf_sql_date" value="#NewTournDate#"> AS
TournDateTime, 0 AS TournDuplicated
FROM clubtournaments
WHERE TournID = <cfqueryparam cfsqltype="cf_sql_integer"
value="#arguments.tid#">
</cfquery>
<cfcatch type="any">
<cfset result = false>
</cfcatch>
</cftry>
<cfreturn result />
</cffunction>
<cffunction name="calcDate" access="public" returntype="date" hint="Returns
1st Saturday of Month">
<cfargument name="id" type="numeric" required="yes">
<cfset var GetTournDate = "">
<cfset var tourndate = "">
<cfset var FirstOfMonth2MonthsAhead = "">
<cfset NewTournDate = "">
<cfquery name="GetTournDate" datasource="SalleBoise">
select TournDateTime
from clubtournaments
where TournID=<cfqueryparam cfsqltype="cf_sql_integer"
value="#arguments.id#">
</cfquery>
<cfset tourndate = GetTournDate.TournDateTime>
<cfset FirstOfMonth2MonthsAhead = createdatetime(year(dateadd('m', 2,
tourndate)), month(dateadd('m', 2, tourndate)), day(tourndate),
hour(tourndate),
minute(tourndate), second(tourndate))>
<cfset NewTournDate = dateadd('d',
7-dayofweek(FirstOfMonth2MonthsAhead), FirstOfMonth2MonthsAhead)>
<cfreturn NewTournDate />
</cffunction>
</cfcomponent>
The problem seems to be happening when the new info is added to the
database. The new DATE is added correctly, but not the TIME... If I do a
dump of whats being stored in NewTournDate, it shows:
{ts '2008-07-05 15:00:00'}
I have my MySql field that I'm storing this info as a Timestamp, and thought
that should be fine. But the time keeps defaulting to 12:00:00, instead of
the 15:00:00 as shown.
Why is this happening?