yii\sphinx\ActiveRecord::delete PHP Метод

delete() публичный Метод

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 index; 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 delete ( ) : integer | false
Результат 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.
    public function delete()
    {
        $db = static::getDb();
        $transaction = $this->isTransactional(self::OP_DELETE) && $db->getTransaction() === null ? $db->beginTransaction() : null;
        try {
            $result = false;
            if ($this->beforeDelete()) {
                // we do not check the return value of deleteAll() because it's possible
                // the record is already deleted in the database and thus the method will return 0
                $condition = $this->getOldPrimaryKey(true);
                $lock = $this->optimisticLock();
                if ($lock !== null) {
                    $condition[$lock] = $this->{$lock};
                }
                $result = $this->deleteAll($condition);
                if ($lock !== null && !$result) {
                    throw new StaleObjectException('The object being deleted is outdated.');
                }
                $this->setOldAttributes(null);
                $this->afterDelete();
            }
            if ($transaction !== null) {
                if ($result === false) {
                    $transaction->rollBack();
                } else {
                    $transaction->commit();
                }
            }
        } catch (\Exception $e) {
            if ($transaction !== null) {
                $transaction->rollBack();
            }
            throw $e;
        }
        return $result;
    }