ditch raw sql

This commit is contained in:
Yuri Kuznetsov
2020-08-25 11:10:06 +03:00
parent fcff23e0c1
commit c8118245e4
+18 -10
View File
@@ -139,16 +139,24 @@ class Notifications
public function afterRemove(Entity $entity)
{
$query = $this->entityManager->getQueryComposer();
$sql = "
DELETE FROM `notification`
WHERE
(related_id = ".$query->quote($entity->id)." AND related_type = ".$query->quote($entity->getEntityType()) .")
OR
(related_parent_id = ".$query->quote($entity->id).
" AND related_parent_type = ".$query->quote($entity->getEntityType()) .")
";
$this->entityManager->getPDO()->query($sql);
$query = $this->entityManager->getQueryBuilder()
->delete()
->from('Notification')
->where([
'OR' => [
[
'relatedId' => $entity->id,
'relatedType' => $entity->getEntityType(),
],
[
'relatedParentId' => $entity->id,
'relatedParentType' => $entity->getEntityType(),
],
],
])
->build();
$this->entityManager->getQueryExecutor()->execute($query);
}
protected function getStreamService()