delete() public method
Deletes the document corresponding to this active record from the collection.
This method performs the following steps in order:
- call beforeDelete(). If the method returns false, it will skip the rest of the steps;
- delete the document from the collection;
- call afterDelete().
In the above step 1 and 3, events named EVENT_BEFORE_DELETE and EVENT_AFTER_DELETE will be raised by the corresponding methods.
public integer|boolean delete ( ) | ||
---|---|---|
return | integer|boolean |
The number of documents deleted, or false if the deletion is unsuccessful for some reason. Note that it is possible the number of documents deleted is 0, even though the deletion execution is successful. |
throws | yii\db\StaleObjectException |
if optimistic locking is enabled and the data being deleted is outdated. |
throws | Exception |
in case delete failed. |
Please login to continue.