3.7.5 Deleting Data

These methods can be used to remove data.

3.7.5.1 del

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.

3.7.5.2 remove

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

A synonym for del().

3.7.5.3 deleteAll

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.