If we are required to delete a record, cakephp 's model class offers a way for the same.
Deleting the record with the perticular id can be done by using delete() function :
delete(integer $id = null, boolean $cascade = true);
The above statement deletes the record with the particular id $id. If the cascade in the function delete(), is set to true it will allow to delete all the records related to this id.
But if we are required to delete all the records we can use the function deleteAll() this function is similar to the delete() function.
Note: deleteAll() function always returns true even if the related records are not deleted as the delete query were successful.
0 Comment(s)