From e17b8dba4bf53ae67aef10cf28519c108a2f4f17 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Sun, 2 Aug 2020 13:55:16 +0300 Subject: [PATCH] orm usage --- application/Espo/Repositories/EmailAddress.php | 16 ++++++++-------- application/Espo/Repositories/PhoneNumber.php | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/application/Espo/Repositories/EmailAddress.php b/application/Espo/Repositories/EmailAddress.php index 3e138b0d6e..1fc9cc3126 100644 --- a/application/Espo/Repositories/EmailAddress.php +++ b/application/Espo/Repositories/EmailAddress.php @@ -411,14 +411,14 @@ class EmailAddress extends \Espo\Core\Repositories\Database implements foreach ($toRemoveList as $address) { $emailAddress = $this->getByAddress($address); if ($emailAddress) { - $query = " - DELETE FROM entity_email_address - WHERE - entity_id = ".$pdo->quote($entity->id)." AND - entity_type = ".$pdo->quote($entity->getEntityType())." AND - email_address_id = ".$pdo->quote($emailAddress->id)." - "; - $sth = $pdo->prepare($query); + $sql = $this->getEntityManager()->getQuery()->createDeleteQuery('EntityEmailAddress', [ + 'whereClause' => [ + 'entityId' => $entity->id, + 'entityType' => $entity->getEntityType(), + 'emailAddressId' => $emailAddress->id, + ], + ]); + $sth = $pdo->prepare($sql); $sth->execute(); } } diff --git a/application/Espo/Repositories/PhoneNumber.php b/application/Espo/Repositories/PhoneNumber.php index 17a083b6a6..4f2b5ce8dc 100644 --- a/application/Espo/Repositories/PhoneNumber.php +++ b/application/Espo/Repositories/PhoneNumber.php @@ -336,14 +336,14 @@ class PhoneNumber extends \Espo\Core\Repositories\Database implements foreach ($toRemoveList as $number) { $phoneNumber = $this->getByNumber($number); if ($phoneNumber) { - $query = " - DELETE FROM entity_phone_number - WHERE - entity_id = ".$pdo->quote($entity->id)." AND - entity_type = ".$pdo->quote($entity->getEntityType())." AND - phone_number_id = ".$pdo->quote($phoneNumber->id)." - "; - $sth = $pdo->prepare($query); + $sql = $this->getEntityManager()->getQuery()->createDeleteQuery('EntityPhoneNumber', [ + 'whereClause' => [ + 'entityId' => $entity->id, + 'entityType' => $entity->getEntityType(), + 'phoneNumberId' => $phoneNumber->id, + ], + ]); + $sth = $pdo->prepare($sql); $sth->execute(); } }