I'm attending CakeFest 2010!

3.7.5 Deleting Data

These methods can be used to remove data.

3.7.5.1 delete

delete(int $id = null, boolean $cascade = true);

Deletes the record identified by $id. By default, also deletes records dependent on the record specified to be deleted.

For example, when deleting a User record that is tied to many Recipe records:

  • if $cascade is set to true, the related Recipe records are also deleted if the models dependent-value is set to true.
  • if $cascade is set to false, the Recipe records will remain after the User has been deleted.

3.7.5.2 remove

remove(int $id = null, boolean $cascade = true);

A synonym for delete().

3.7.5.3 deleteAll

deleteAll(mixed $conditions, $cascade = true, $callbacks = false)

Same as with delete() and remove(), except that deleteAll() deletes all records that match the supplied conditions. The $conditions array should be supplied as an SQL fragment or array.