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.
Name | Type | Required | Default | Description |
---|---|---|---|---|
parameterize | any | No | true | Set to true to use cfqueryparam on all columns, or pass in a list of property names to use cfqueryparam on those only. |
transaction | string | No | [runtime expression] | Set this to commit to update the database when the save has completed, rollback to run all the database queries but not commit them, or none to skip transaction handling altogether. |
callbacks | boolean | No | true | Set to false to disable callbacks for this operation. |
includeSoftDeletes | boolean | No | false | You can set this argument to true to include soft-deleted records in the results. |
softDelete | boolean | No | true | Set to false to permanently delete a record, even if it has a soft delete column. |
delete([ parameterize, transaction, callbacks, includeSoftDeletes, softDelete ]) <!--- Get a post object and then delete it from the database ---> <cfset post = model("post").findByKey(33)> <cfset post.delete()> <!--- If you have a `hasMany` association setup from `post` to `comment`, you can do a scoped call. (The `deleteComment` method below will call `comment.delete()` internally.) ---> <cfset post = model("post").findByKey(params.postId)> <cfset comment = model("comment").findByKey(params.commentId)> <cfset post.deleteComment(comment)>