Build a delete query for an entity.
@param type $entity
@return string
502253
public function buildDeleteQuery($entity) {
        $mapper = MapperBuilder::buildFromMapping($this->mapping, get_class($entity));
        $query = "";
        foreach ($mapper->getRelations() as $relation) {
            $query .= $this->buildDeleteRelationQuery($relation, $entity);
        }

        $query .= "DELETE FROM " . $mapper->getTable() . " ";
        $query .= "WHERE id = '" . $entity->getId() . "';";

        return $query;
    }
791874
public function delete($entity)
    {
        $identifier   = $this->getIdentifier($entity);
        $affectedRows = $this->connection->delete($this->tableName, $identifier);

        if ($affectedRows == 0) {
            throw new OrmException("Entity not found.");
        }
    }
649483
protected function storeEntity($entity)
    {
        $this->checkEntityType($entity);

        $store = new Store($this->aggregate($entity), $this->newQueryBuilder());

        return $store->execute();
    }
1307293
public function getMapperFor($entity)
    {
        return  $this->mappers->containsKey($entity)
            ? $this->mappers->get($entity)
            : $this->createMapper($entity);
    }
1079435
public function deleteEntity(SearchableEntityInterface $entity)
    {
        foreach ($this->locales as $locale) {
            $uid       = $this->getDocUid($entity, $locale);
            $indexType = $this->indexType;
            $this->searchProvider->deleteDocument($this->indexName, $indexType, $uid);
        }
    }
1115769
public function remove($entity)
    {
        if ($this->evm->hasListeners(Events::preRemove)) {
            $this->evm->dispatchEvent(Events::preRemove, new Event\LifecycleEventArgs($entity, $this->sm));
        }

        $oid = spl_object_hash($entity);
        $this->scheduledForDelete[$oid] = $entity;

        if ($this->evm->hasListeners(Events::postRemove)) {
            $this->evm->dispatchEvent(Events::postRemove, new Event\LifecycleEventArgs($entity, $this->sm));
        }
    }
1116027
public function transform($entity)
    {
        if (null === $entity) {
            return '';
        }
        if (!is_subclass_of($entity, $this->entityClass)) {
            throw new \InvalidArgumentException(sprintf(
                'Unsupported entity "%s" into "%s" loader.',
                get_class($entity),
                __CLASS__
            ));
        }

        return $entity->getId();
    }
1170361
public function delete($table = "")
    {
        if (empty($table)) {
            $table = $this->structure->tableName; // @codeCoverageIgnore
        }

        $this->table = $table;
        $this->queryType = self::QUERY_DELETE;

        return $this;
    }
137459
private function getEntityIdentifierValue($entity)
    {
        $entityMetaData = $this->entityManager->getEntityMetadataRegister()->getEntityMetadata($entity);

        return $entityMetaData ? $entityMetaData->getIdentifierValue() : null;
    }
969369
public function destroy(Entity $entity)
    {
        if ($entity->isExists()) {

            // enable logical delete ?
            if ($entity->hasAttribute('active')) {
                $attributes = [];
                $attributes['active'] = 0;
                if ($entity->hasAttribute('deleted_at')) $attributes['deleted_at'] = time();
                $this->update($attributes, $entity->getPrimaryValue());
            } else {
                $this->delete($entity->getPrimaryValue());
            }
        }
    }
749466
public function deleteEntity(EntityInterface $entity)
    {
        $delete = $this->tableGateway->getSql()->delete();
        $delete->where->equalTo(
            $this->tableGateway->getPrimaryKey(), $entity->getIdentifier()
        );

        try {
            $this->tableGateway->deleteWith($delete);
        } catch (RuntimeException $e) {
            return false;
        }

        return true;
    }
99052
public function deleteEntityById($entity, $id)
    {
        $tbl = $this->_resource->getTableName($entity);
        $where = [];
        foreach ($id as $field => $value) {
            $where["`$field`=?"] = $value;
        }
        $result = $this->_conn->delete($tbl, $where);
        return $result;
    }
48421
public static function delete($entity): ResultInterface
    {
        $className = \get_class($entity);
        list($table, , , $fields) = self::getFields($entity, 3);
        $instance = self::getInstance($className);

        $query = Query::table($table)->selectInstance($instance);
        foreach ($fields ?? [] as $column => $value) {
            $query->where($column, $value);
        }

        return $query->delete();
    }
830237
public function delete($entity) {
        $deleteQuerys = $this->buildDeleteQuery($entity);
        foreach (explode(";", $deleteQuerys) as $q) {
            if (strlen($q) > 5)
                $this->conn->executeNonQuery($q);
        }
        return true;
    }
889019
public final function remove(Entity $entity): int
    {
        $primaryValue = $entity->getPrimaryValue();
        if ($primaryValue === null) {
            throw new InvalidValueException('Primary value not found on entity for delete action!');
        }

        return $this->removeAll($primaryValue);
    }
590499
public function removeEntity($entity)
    {
        $this->entityManager->remove($entity);
        $this->entityManager->flush();
        return true;
    }
1289693
public function delete($entity)
    {
        if (!$this->isRepositoryDeletable()) {
            throw $this->createNotDeletableException();
        }

        return $this->trigger(__FUNCTION__, [
            'entity' => $entity,
        ]);
    }