3.7.5 Deleting Data

remove(int $id = null, boolean $cascade = true);
del(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 $cascade is set to false, the Recipe records will remain after the User has been deleted.
deleteAll(mixed $conditions, $cascade = true)

Same as with del() 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.