db\ActiveRecord delete()

delete() public method

Deletes the table row corresponding to this active record.

This method performs the following steps in order:

  1. call beforeDelete(). If the method returns false, it will skip the rest of the steps;
  2. delete the record from the database;
  3. 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|false delete ( )
return integer|false

The number of rows deleted, or false if the deletion is unsuccessful for some reason. Note that it is possible the number of rows 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.

doc_Yii
2016-10-30 16:56:17
Comments
Leave a Comment

Please login to continue.