| Package: machii_info_sample.model.comment |
| I abstract data access for comments |
| Method Summary | |
|---|---|
| public commentdao | init(string dsn) |
| public void |
create()
CRUD method |
| public void |
delete(comment comment)
CRUD method |
| public void |
read(comment comment, numeric commentID)
CRUD method |
| public void |
update(comment comment)
CRUD method |
| Method Detail |
|---|
| create |
|---|
public void create( )
CRUD method
Parameters:
Code:
<cffunction name="create" returntype="void" output="false" hint="CRUD method"> <cfabort showerror="commentDAO.create - This Method is Abstract and needs to be overridden"> </cffunction>
| delete |
|---|
public void delete( comment comment )
CRUD method
Parameters:
| comment comment |
Code:
<cffunction name="delete" returntype="void" output="false" hint="CRUD method"> <cfargument name="comment" type="comment" required="true" /> <cfset commentDelete = 0 > <cfquery name="commentDelete" datasource="#variables.dsn#" > DELETE FROM comments WHERE commentID = <cfqueryparam cfsqltype="CF_SQL_INTEGER" value="#arguments.comment.getCommentID()#" > </cfquery> </cffunction>
| init |
|---|
public commentdao init( string dsn )
Parameters:
| string dsn |
Code:
<cffunction name="init" access="public" returntype="machii_info_sample.model.comment.commentdao" output="false" > <cfargument name="dsn" type="string" required="true" /> <cfset variables.dsn = arguments.dsn /> <cfreturn this /> </cffunction>
| read |
|---|
public void read( comment comment, numeric commentID )
CRUD method
Parameters:
| comment comment |
| numeric commentID |
Code:
<cffunction name="read" access="public" returntype="void" output="false" hint="CRUD method"> <cfargument name="comment" type="machii_info_sample.model.comment.comment" required="yes" displayname="read" hint="I am the comment object into which data is read." /> <cfargument name="commentID" type="numeric" required="true" hint="I am the ID of the database record to read." /> <cfset var commentSelect = 0 /> <cfquery name="commentSelect" datasource="#variables.dsn#"> SELECT * FROM comments WHERE commentID = <cfqueryparam cfsqltype="CF_SQL_INTEGER" value="#arguments.commentID#" > </cfquery> <cfif commentSelect.recordCount > <cfscript> arguments.comment.setCommentID(commentSelect.commentID); arguments.comment.setFaqID(commentSelect.faqID); arguments.comment.setComment(commentSelect.comment); arguments.comment.setCreatedByUserID(commentSelect.createdByUserID); </cfscript> <cfelse> <cfthrow message="commentID #arguments.commentID# not found" type="comment" detail="" errorcode="comment.commentNotFound" extendedinfo="" > </cfif> </cffunction>
| update |
|---|
public void update( comment comment )
CRUD method
Parameters:
| comment comment |
Code:
<cffunction name="update" returntype="void" output="false" hint="CRUD method"> <cfargument name="comment" type="comment" required="true" /> <cfset commentUpdate = 0 > <cfquery name="commentUpdate" datasource="#variables.dsn#" > UPDATE comments SET comment = '#trim(arguments.comment.getComment())#' WHERE commentID = <cfqueryparam cfsqltype="CF_SQL_INTEGER" value="#arguments.comment.getCommentID()#" > </cfquery> </cffunction>