db = $db; } /** * @param string $emailAddress * * @return int|null */ public function tryGetAddressIdByEmailAddress(string $emailAddress): ?int { $values = ['email_address' => $emailAddress]; $searchByEmail = 'SELECT a.id FROM `adresse` AS `a` WHERE a.email LIKE :email_address AND a.geloescht = 0 ORDER BY a.id DESC'; $id = $this->db->fetchValue($searchByEmail, $values); if ($id !== null && $id > 0) { return $id; } $searchByResponsePerson = 'SELECT ap.adresse FROM `ansprechpartner` AS `ap` WHERE ap.email LIKE :email_address ORDER BY ap.id DESC'; $id = $this->db->fetchValue($searchByResponsePerson, $values); if ($id !== null && $id > 0) { return $id; } $searchByContactInfo = 'SELECT ak.adresse FROM `adresse_kontakte` AS `ak` WHERE ak.kontakt LIKE :email_address ORDER BY ak.id DESC'; $id = $this->db->fetchValue($searchByContactInfo, $values); return $id; } }