<cffunction
name="Load"
access="public"
returntype="any"
output="false"
hint="I load and return a comment object based on the given ID. If no comment is found, throws an exception.">
<cfargument
name="ID"
type="numeric"
required="true"
hint="I am the ID of the given comment."
/>
<cfset var LOCAL = {} />
<cfquery name="LOCAL.CommentData" datasource="#VARIABLES.DSN.Source#">
SELECT
c.id,
c.comment,
c.date_created,
c.photo_id
FROM
comment c
INNER JOIN
photo p
ON
(
c.photo_id = p.id
AND
p.id = <cfqueryparam
value="#ARGUMENTS.ID#"
cfsqltype="cf_sql_integer"
/>
)
ORDER BY
c.date_created ASC
</cfquery>
<cfif LOCAL.CommentData.RecordCount>
<cfset LOCAL.Comments =
VARIABLES.LoadObjectsFromQuery(
LOCAL.CommentData
) />
<cfreturn LOCAL.Comments[ 1 ] />
<cfelse>
<cfthrow
type="OOPhoto.InvalidComment"
message="The selected comment could not be found."
detail="The comment with ID #ARGUMENTS.ID# could not be found."
/>
</cfif>
</cffunction>