src/Db/Orm/ActiveRecord.php
public function delete()
    {
        if (!$this->isTransactional(self::OP_DELETE)) {
            return $this->deleteInternal();
        }

        $transaction = static::getDb()->createTransaction();
        return $transaction->begin()->thenLazy(
            function(ConnectionInterface $connection) {
                return $this->deleteInternal($connection);
            }
        )->thenLazy(
            function($result) use ($transaction) {
                return $transaction->commit()->then(function() use ($result) {
                    return $result;
                });
            },
            function($exception) use ($transaction) {
                return $transaction->rollBack()->then(
                    function() use ($exception) { throw $exception; },
                    function($e) use ($exception) { throw $exception; }
                );
            }
        );
    }
public function delete()
    {
        if (!$this->isTransactional(self::OP_DELETE)) {
            return $this->deleteInternal();
        }

        $transaction = static::getDb()->createTransaction();
        return $transaction->begin()->thenLazy(
            function(ConnectionInterface $connection) {
                return $this->deleteInternal($connection);
            }
        )->thenLazy(
            function($result) use ($transaction) {
                return $transaction->commit()->then(function() use ($result) {
                    return $result;
                });
            },
            function($exception) use ($transaction) {
                return $transaction->rollBack()->then(
                    function() use ($exception) { throw $exception; },
                    function($e) use ($exception) { throw $exception; }
                );
            }
        );
    }
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.

@return LazyPromiseInterface with int|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 \Exception|\Throwable in case delete failed.