Today I wanted to implement some functionality to delete all records of a table. Easy, there is a deleteAll() method in the Model class I can use for this purpose. So I wrote the following statement:

$this->MyModel->deleteAll(array(), false);

As I executed that code, nothing happened. No delete statement was generated. Hm. So I looked at the source of the deleteAll() method, and what’s there? The method simply returns false if you provide an empty $conditions parameter:

if (empty($conditions)) {
    return false;
}

And as this is not a bug (see ticket 3699), this means you have to provide a dummy condition if you want to delete all entries of a table:

$this->MyModel->deleteAll(array('1 = 1'), false);

or

$this->MyModel->deleteAll('1 = 1', false);

It’s a bit ironic that you have to use a workaround when using deleteAll() to delete all entries of a table, isn’t it? ;-)