delete()
Description
Deletes the object, which means the row is deleted from the database (unless prevented by a beforeDelete callback). Returns true on successful deletion of the row, false otherwise.
Function Syntax
delete([ parameterize ])
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
parameterize |
any |
No | true |
Accepts a boolean value or a string. Set to true to use cfqueryparam on all columns or pass in a list of property names to use cfqueryparam on those only. |
Examples
<!--- Get a post object and then delete it from the database --->
<cfset aPost = model("post").findByKey(33)>
<cfset aPost.delete()>
<!--- If you have a `hasMany` association setup from `post` to `comment` you can do a scoped call (the `deleteComment` method below will call `aComment.delete()` internally) --->
<cfset aPost = model("post").findByKey(params.postId)>
<cfset aComment = model("comment").findByKey(params.commentId)>
<cfset aPost.deleteComment(aComment)>
